On Friday 09 March 2001 07:44, you wrote:
> tail -f /var/log/syslog | grep "foobar" > foobar.txt | mailfile foobar.txt
> [EMAIL PROTECTED]

Well, the first reason this won't work as written is because of your use of 
'tail -f' rather than plain 'tail'. 'tail -f' is basically 'tail forever', 
and since it never closes stdout, there will be nothing for you to see at the 
other side of the pipe. 

If you want to just tail the last 10 or so lines of your file, use 'tail' by 
itself, or give the tail command an argument for tne number of lines you want 
to see.

> however that doesn't work like I thought it would.  I looked up tee and it
> says that it redirects STDIN to STDOUT so I was thinking that maybe I could

Think of it just like a plumber's 'tee' (I'm not a plumber, either) :) in 
that you have a pipe, and you have this t-shaped thing that has two pipes on 
the end - one goes to the rest of the command / pipe chain, and the other 
might go into another file,

In your situation it appears that you want to tall so many lines out of the 
syslog, search for 'foobar', and mail the results to yourself, but also send 
these results to a file somewhere. That's what it looks like you want to do 
:).

Here, you probably want to mail the results of the command's (or pipe's)
stdout:

tail -20 /var/log/syslog | grep foobar - | mail -s "output" [EMAIL PROTECTED] 

OK, that should suffice to mai the output, but what about the file? Insertion 
of a 'tee' just before the 'mail' part of that command line should do the 
trick:

tail -20 /var/log/syslog | grep foobar - | tee - >wowie | mail -s "output" 
[EMAIL PROTECTED]

-- 
------------------------------------------------------------------------
David E. Fox                              Thanks for letting me
[EMAIL PROTECTED]                            change magnetic patterns
[EMAIL PROTECTED]               on your hard disk.
-----------------------------------------------------------------------

Reply via email to