#1  
Old 18th May 2006, 00:53
sjau sjau is offline
Pseudo Lawyer
 
Join Date: Apr 2006
Location: Switzerland
Posts: 857
Thanks: 3
Thanked 25 Times in 23 Posts
Default Bash: Assigning variables

Hiya

I have a little code snippet like this:

Code:
LINK=`/bin/grep -f http://www.spamcop.net/sc?id= $FILENAME`
echo $LINK
LINK=`/bin/fgrep http://www.spamcop.net/sc?id= $FILENAME`
echo $LINK
LINK=`/bin/ls $FILENAME`
echo $LINK
The output is this:

Code:
grep: http://www.spamcop.net/sc?id=: No such file or directory

/bin/fgrep: line 2: exec: grep: not found

1147891663.9720_2.t390.greatnet.de:2,ST
grep: http://www.spamcop.net/sc?id=: No such file or directory

/bin/fgrep: line 2: exec: grep: not found

1147896741.16696_2.t390.greatnet.de:2,ST
Why do grep and fgrep not work but the ls does?
Reply With Quote
  #2  
Old 18th May 2006, 21:41
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,853
Thanks: 781
Thanked 1,558 Times in 1,477 Posts
Default

I don't think you can use grep for files that aren't on the same system.
__________________
Falko
--
Follow me on:
Reply With Quote
  #3  
Old 18th May 2006, 22:10
sjau sjau is offline
Pseudo Lawyer
 
Join Date: Apr 2006
Location: Switzerland
Posts: 857
Thanks: 3
Thanked 25 Times in 23 Posts
Default

They are on the same system but I have to use grep -F and not grep -f ^^

But I still wonder why fgrep does not work...
Reply With Quote
  #4  
Old 19th May 2006, 16:30
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,853
Thanks: 781
Thanked 1,558 Times in 1,477 Posts
Default

But you can't use grep with URLs, no matter if they point to the same system.
__________________
Falko
--
Follow me on:
Reply With Quote
  #5  
Old 19th May 2006, 16:35
sjau sjau is offline
Pseudo Lawyer
 
Join Date: Apr 2006
Location: Switzerland
Posts: 857
Thanks: 3
Thanked 25 Times in 23 Posts
Default

Not sure what you mean. The shell script looks like this now:

Code:
#!/bin/bash

# ENTER PATH OF THE VERIFICATION EMAILS FROM SPAMCOP
PATH="/home/mail/web4p1/Maildir/.Spamcop-Reply/cur"

# ENTER WEBPATH TO PHP SCRIPT
URL="http://www.roleplayer.org/spamcop.php"

#################################################################
#################################################################

cd $PATH

for FILENAME in *S
do

        LINK=`/bin/grep -F http://www.spamcop.net/sc?id= $FILENAME`
        echo $LINK
#        LINK=`/bin/fgrep http://www.spamcop.net/sc?id= $FILENAME`
#        echo $LINK
#       LINK=`/bin/ls $FILENAME`
#       echo $LINK
#       lynx -dump $URL?link=$LINK


#       /bin/rm $FILENAME

done
Reply With Quote
  #6  
Old 21st May 2006, 22:45
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,853
Thanks: 781
Thanked 1,558 Times in 1,477 Posts
Default

You can use grep with local files, e.g.
Code:
grep bla /path/to/example.txt
, but not with URLs, like
Code:
grep bla http://www.example.com/example.txt
__________________
Falko
--
Follow me on:
Reply With Quote
  #7  
Old 22nd May 2006, 21:07
neil6179 neil6179 is offline
Junior Member
 
Join Date: Mar 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could use wget to download the file then pipe it into grep.

Code:
wget -q -O - "http://www.example.com/example.txt" | grep bla
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash - reading stuff from MySQL.. edge Programming/Scripts 3 4th April 2006 15:49
req: Bash / Script to auto kill PID if it's needed.... edge Programming/Scripts 8 14th March 2006 00:31
Bash - Deleting duplicate records Wire323 Programming/Scripts 4 8th March 2006 14:26
bash scripting for begginers aolex Suggest HOWTO 4 21st October 2005 16:45


All times are GMT +2. The time now is 22:05.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Sponsored Links: Unified Communications: Thoughts, Strategies and Predictions
Join the discussion.
www.seamlessenterprise.com

IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com

Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com

Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com

Red Hat Virtual Experience - a free virtual event. Dec. 9th