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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 02-18-2004, 07:04 PM   #1
Dusen
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?
__________________
Penis Pill Sponsor List and Reviews:
http://www.pillsponsors.com
Dusen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2004, 07:09 PM   #2
Veiga
Confirmed User
 
Join Date: Jun 2001
Location: Portugal
Posts: 157
That's correct, and I just tried and it works with me.

Is the file created but empty?
__________________
Sell me your portuguese Traffic!
Euro Luso
Veiga is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-18-2004, 07:12 PM   #3
Dusen
Confirmed User
 
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
Yes, that is what is happening.
__________________
Penis Pill Sponsor List and Reviews:
http://www.pillsponsors.com
Dusen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-19-2004, 06:44 AM   #4
Dusen
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.
__________________
Penis Pill Sponsor List and Reviews:
http://www.pillsponsors.com
Dusen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-19-2004, 06:49 AM   #5
com
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]
com is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-19-2004, 07:17 AM   #6
Dusen
Confirmed User
 
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
PHP Code:
#!/usr/bin/perl

while (1) {
open LOG'access_log' || die "no can open file: $!";

seek(LOG,0,2);
for(;;) {
headerloop: while(<LOG>)
{
        
chomp;
        if (/.*(
texttofilter).*/)
        {
        
open YOURLOG'>> /home/me/outputfile' || die "can not write to file";
        print 
YOURLOG "$_","\n";
        }

}
sleep(1);
seek(LOG,0,1);
close YOURLOG;
}

Thanks

The grep option works without sending to file AND sending to file works without the grep there. It seems that soemthing is messed up.
__________________
Penis Pill Sponsor List and Reviews:
http://www.pillsponsors.com
Dusen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-19-2004, 06:11 PM   #7
Dusen
Confirmed User
 
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
Bump?
__________________
Penis Pill Sponsor List and Reviews:
http://www.pillsponsors.com
Dusen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-19-2004, 06:16 PM   #8
com
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]
com is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-19-2004, 06:19 PM   #9
com
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]
com is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-19-2004, 06:22 PM   #10
Dusen
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.
__________________
Penis Pill Sponsor List and Reviews:
http://www.pillsponsors.com
Dusen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-20-2004, 07:59 AM   #11
Dusen
Confirmed User
 
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
A Final Bump
__________________
Penis Pill Sponsor List and Reviews:
http://www.pillsponsors.com
Dusen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-20-2004, 08:04 AM   #12
Alky
Confirmed User
 
Alky's Avatar
 
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?
Alky is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-20-2004, 08:30 AM   #13
some_idiot
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.
__________________

This AVS pays my mortgage!
some_idiot is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-20-2004, 08:34 AM   #14
extreme
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.
extreme is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-20-2004, 08:54 AM   #15
extreme
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.
extreme is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-20-2004, 10:04 AM   #16
Dusen
Confirmed User
 
Join Date: Aug 2002
Location: East Coast.
Posts: 2,251
Quote:
Originally posted by extreme
and ...

tail -f file | awk '/term/ { print; fflush() }' > file.txt

.. solves it.
Outstanding, it sure does.

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
__________________
Penis Pill Sponsor List and Reviews:
http://www.pillsponsors.com
Dusen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.