On 13Oct2006 20:59, Michael Sullivan <[EMAIL PROTECTED]> wrote:
| #!/bin/sh
|
| while read line
| do
| echo "Processing $line..."
| for x in *,*; do
| echo "Filename: $x"
| grep "$line" "$x"
| if [ $? -eq 0 ]; then #We found a match
| whois $line | grep 'abuse'
| echo 'Abuse address, please?'
| #At this point the script should pause and wait for input
| #from the keyboard.
| read abuse;
| subject=`grep 'Subject' "$x"`
| subject=${subject/Subject/Fwd}
| echo "To: $abuse"
| echo "Subject: $subject"
| cat $x
| fi
| done
| done < yesabuse.txt
|
| This script works well, except that it doesn't stop to ask for input
| for the $abuse variable. I guess it gets it from what should go to
| $line. How can I make it stop and take input from the keyboard?
Well, "read line" reads from stdin, not "the terminal". And stdin is the
yesabuse.txt file.
Attach yesabuse.txt to a different file descriptor and leave stdin
alone:
while read line <&3
do
...
done 3<yesabuse.txt
File descriptors 0, 1 and 2 are stdin, stdout, stderr. The others are
generally available for use.
Don't forget you can close a file descriptor like this:
exec 3<&-
but for this example it is unnecessary - like all other commands, the
3<yesabuse.txt is opened for the while loop and closed afterwards, just
as it would be for this:
some-command-the-expects-fd-3 3<yesabuse.txt
Cheers,
--
Cameron Simpson <[EMAIL PROTECTED]> DoD#743
http://www.cskk.ezoshosting.com/cs/
When we say we want sensitive men, we mean 'thoughtful and considerate', not
'easily wounded'. - Susie, friend of Julie Wright <[EMAIL PROTECTED]>
To unsubscribe from this list, please email [EMAIL PROTECTED] & you will be
removed.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/LINUX_Newbies/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/LINUX_Newbies/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/