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?
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.
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.
Summary: James: thats what I had origionally thought too but doing: cp file1 file2 | tail -f file2 makes it unreadable as it scrolls by, and also if you do do it that way you will need to ^C at the end to get ...
Summary: You view either the last few lines, a parameter you pass as tail -10 file will show you the last 10 lines then quit. tail -f file will continously read file until you force a quit with CONTROL - C. ...
Summary: I am having a problem with writing a script in UNIX that will take a user's input(age) and display whether the user is a minor, adult, or senior. One of the stipulations is there are 3 age brackets....