![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
|
Unix Help - Tail | Grep
I'm trying to grep a tail -f out to a file.
But it doesn't seem to be working. I am doing: tail -f file | grep 'term' > file.txt No output to file. Anyone see what is wrong? Any ideas how to do this? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
|
Yes, that is what is happening.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
|
Anyone else help? I'm stuck.
I've scripted something up in perl but when the file gets truncated the perl script stops outputting to file. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Join Date: Aug 2003
Location: Portland, Oregon
Posts: 4,541
|
looks fine to me, post your code
__________________
Real. Professional. Hosting. .:Expect Nothing Less:. 320-078-843 :: www.realprohosting.com :: [email protected] |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
|
PHP Code:
![]() The grep option works without sending to file AND sending to file works without the grep there. It seems that soemthing is messed up. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Confirmed User
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
|
Bump?
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Join Date: Aug 2003
Location: Portland, Oregon
Posts: 4,541
|
hrm, perhaps you might try using 2&>/path/to/file
edit I havent touched perl in ages but what you've got there looks fine to me.
__________________
Real. Professional. Hosting. .:Expect Nothing Less:. 320-078-843 :: www.realprohosting.com :: [email protected] |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Confirmed User
Join Date: Aug 2003
Location: Portland, Oregon
Posts: 4,541
|
im sure im probably mistaken but shouldn't
>> /home/me/outputfile be > /home/me/outputfile or at least have a statement to use concatonate or append depending on weather or not the file exists. *shrug*
__________________
Real. Professional. Hosting. .:Expect Nothing Less:. 320-078-843 :: www.realprohosting.com :: [email protected] |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Confirmed User
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
|
Hrmm, well depending on what I want to do, >> is just because I don't want to kill what is there now. Appending is much better for me.
I don't even need to use that script, I just need to tail -f a logfile and grep the output to another file. That's it. I'm lost. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Confirmed User
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
|
A Final Bump
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Confirmed User
Join Date: Apr 2002
Location: Houston
Posts: 5,651
|
hate to ask a stupid question, but is there anything in the file your trying to tail?
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
Confirmed User
Join Date: May 2002
Location: Doesn't matter, I'm not buying you another pint!
Posts: 1,511
|
It's the way that grep dumps the data pipe into standard out.
Give who | sort >> user.txt a try and I bet it works for you. You're going to need to write a quick hack in perl to open a file and then dump all standard input to it. Stick that in place of the >> yourfile in your pipe chain. tail | grep | hack.pl ...or spend all day pulling your hair out searching for an answer you probably won't find. ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 |
Confirmed User
Industry Role:
Join Date: Oct 2002
Location: lalaland
Posts: 2,120
|
output buffering .. need to reach a certain amount of lines before the last pipe gets it.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 |
Confirmed User
Industry Role:
Join Date: Oct 2002
Location: lalaland
Posts: 2,120
|
and ...
tail -f file | awk '/term/ { print; fflush() }' > file.txt .. solves it. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#16 | |
Confirmed User
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
|
Quote:
Thanks a BUNCH, I really appreciate it. Thanks to everyone who helped in this thread, I knew there were some fellow nix dorks lurking around here and I wasn't alone. J |
|
![]() |
![]() ![]() ![]() ![]() ![]() |