[lug] Trapping Tcpdump Output
D. Stimits
stimits at idcomm.com
Sun Oct 7 12:53:20 MDT 2001
rm at fabula.de wrote:
>
> On Sun, Oct 07, 2001 at 12:29:53PM -0600, D. Stimits wrote:
> >
> > An expansion on the topic. For bash:
> > whatever &1<2 | your_script
> >
> > For tcsh/csh:
> > whatever |& your_script
> >
> > Add this if you want to both log something, and also view it, same time
> > (bash version):
> > whatever &1<2 | tee logfile
> >
> > Variation to view and use script:
> > whatever &1<2 | tee logfile | your_script
>
> Redirecting output from _within_ the script might be helpfull sometimes.
> Bash allows this with a special neat trick:
>
> exec 2> mylogfile
>
> I sometimes use this idiom in startup scripts (/etc/init.d stuff mainly)
> where i want the output of the script in the logfile of the server i want
> to start and not on the console.
>
> Ralf
> _______________________________________________
> Web Page: http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
Since the script is for tcpdump in particular, it might be convenient to
run tcpdump from within the script as well (taking the above a step
further). Even "tee" could be run from within the script (the log file
could be given a full path if this will be reused, or left relative).
D. Stimits, stimits at idcomm.com
More information about the LUG
mailing list