Computing.Net > Forums > Unix > tail -f as input?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

tail -f as input?

Reply to Message Icon

Name: LANkrypt0
Date: September 9, 2003 at 11:18:30 Pacific
OS: UNIX/KSH
CPU/Ram: 128
Comment:

Not sure exaclty how to say this or if this is the right way to do this but:

Say I have a file that is constantly written to, and I want to take the continual input as input for a script, how would that be done?

I tried:
tail -f inputfile | scriptname

But that didnt work, perhaps there is something I need to write in the scriptname to accept that input? Or is it different syntax on the tail?

Doing this in KSH.

Again sorry for the bad description, but any help would be greatly appreciated.

Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: James Boothe
Date: September 10, 2003 at 06:38:00 Pacific
Reply:

I did it two ways with no problem.  In both cases, I was simply echoing the lines received from the tail command.  And in both cases, the scripts keep running until I interrupt them, even if there are no writers to the file being tailed.

./proctail1.ksh

#!/bin/ksh
IFS=
tail -f inputfile |
while read line
do
echo $line
done
exit 0

and the second way:

tail -f inputfile | ./proctail2.ksh

#!/bin/ksh
IFS=
while read line
do
echo $line
done
exit 0

What exactly is happening in your case?


0

Response Number 2
Name: LANkrypt0
Date: September 12, 2003 at 06:54:14 Pacific
Reply:

Mine just hung there. It would look as though it was reading, but when data was passed to inputfile, the script would not pick it up and echo it.

Was quite weird.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: tail -f as input?

Re:Unix query www.computing.net/answers/unix/reunix-query/3286.html

question about tail www.computing.net/answers/unix/question-about-tail/5572.html

ask for users age as input www.computing.net/answers/unix/ask-for-users-age-as-input/6501.html