|
Programming C, bash, Python, Perl, PHP, Java, you name it. |
|
Thread Tools | Display Modes |
|
|||
echo tcpdump date to an output
how to echo the output displayed of command "tcpdump -r /var/log/pflog -o -ttt -vv -e -n" to an output file in shell script?
|
|
||||
You mean:
tcpdump -r /var/log/pflog -o -ttt -vv -e -n > /var/log/outputfile or tcpdump -r /var/log/pflog -o -ttt -vv -e -n >> /var/log/outputfile ? http://www.google.com/search?q=shell+redirection |
|
||||
Another option is script(1).
Example: $ script Script started, output file is typescript $ sudo tcpdump -r <whatever> $ ifconfig <whatever> $ <whatever> . . . $ exit Script done, output file is typescript $ col -b < typescript > session.log.for.today $ less session.log.for.today |
|
|||
This is my script
Code:
#!/bin/ksh # #Reading file read ANSWER?"Enter location file to read: " #check source file if [[ ! -f $ANSWER ]] then print "$ANSWER: File not found or not accessible, make sure your enter t he right path." exit 1 else #Name the output file read OUTPUT?"Give a name to the output file: " #write to file echo $(tcpdump -r $ANSWER -o -ttt -vv -e -n) > $OUTPUT fi ~ |
|
|||
I think the problem could be the exec command of my previous work.
Code:
exec 0<$ANSWER |
|
||||
Quote:
__________________
Kill your t.v. |
|
|||
I tried to do it in a sample text file. I use awk to sort the text file and echo to an output file. When i check the output file it doesn't print in new line but in 1 line. I got 3 line of text in the file. Here is my echo .
Code:
echo $(awk '{ print $1 }' $File | sort | uniq -c | sort -nr) > $Output Last edited by bsdnewbie999; 8th April 2009 at 06:10 AM. Reason: edited |
|
||||
@ bsdnewbie999: Sorry if my post seemed too cryptic; maybe it's a language problem.
My suggestion was to replace this Code:
echo $(tcpdump -r $ANSWER -o -ttt -vv -e -n) > $OUTPUT Code:
tcpdump -r $ANSWER -o -ttt -vv -e -n > $OUTPUT |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
tcpdump package | bsdnewbie999 | OpenBSD Packages and Ports | 6 | 30th March 2009 05:24 PM |
tcpdump snaplen WARNING | bsdnewbie999 | OpenBSD General | 1 | 17th March 2009 03:24 AM |
i would like to know about tcpdump | chamnanpol | FreeBSD General | 8 | 17th September 2008 11:00 AM |
Using Date variable? | cwhitmore | FreeBSD General | 9 | 13th August 2008 07:16 AM |
Help with tcpdump file | brokensilence | General software and network | 2 | 10th July 2008 03:45 PM |