Script to capture snoop output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to capture snoop output
# 1  
Old 03-21-2010
Script to capture snoop output

Hi Everyone Smilie,
Need your advice as I'm new to UNIX scripting.. I'm trying to write a script to capture snoop output for 5 minutes for every hour for 24 hours. To stop snoop, I need to press Control-C to break it. This is what I got so far, but now I'm stuck! Smilie

The script:
Code:
# cat snoop.sh
#!/bin/ksh
file="/tmp/snoop.`date '+%m%d%y'`"
while true
do
  snoop -P > $file
  if [ -e $file ]
  then
    echo "File created"
    break
  fi
  echo "Snoop completed"
done

Debug:
Code:
# ksh -vx snoop.sh
#!/bin/ksh
file="/tmp/snoop.`date '+%m%d%y'`"
+ + date +%m%d%y
file=/tmp/snoop.032110
while true
do
  snoop -P > $file
  if [ -e $file ]
  then
    echo "File created"
    break
  fi
  echo "Snoop completed"
done
+ true
+ snoop -P
+ 1> /tmp/snoop.032110
Using device /dev/ce (non promiscuous)
^C#

Thank you.. Smilie

Last edited by Scott; 03-21-2010 at 08:44 PM.. Reason: Please indent your code and use code tags
# 2  
Old 03-22-2010
I have a idea we send the snoop to back ground. Then we can have a separate pid for it.

After 5 mins kill that pid with INT signal ( same as CTRL+C).

Code:
#!/bin/bash -x
file=amit123
echo $file
nohup  snoop -P > $file &
sleep 300
echo $!
kill -INT $!

  if [ -e $file ]
  then
    echo "File created"
else
echo "some error occured"
  fi
  echo "Snoop completed"

# 3  
Old 03-27-2010
hi amitranjansahu,
thanks for your help :)

"kill -INT $!" is the one I'm looking for..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture output from expect script

Hi I am new to Expect scripting. I have to connect to a remote server and capture the output. Here I need output of " send "list registered\r"" to be stored in a file. but after execution, /tmp/capture.txt is of 0 byte #!/usr/bin/expect spawn ssh abc@10.10.10.10 -p 5022 expect... (2 Replies)
Discussion started by: bns928
2 Replies

2. Solaris

How to read the output of snoop command?

Hi! I have run the following command: snoop -q -d e1000g0 -o /var/tmp/optima0.txt & them I am trying to read the output of it with snoop -i /var/tmp/optima0.txt, which is giving me this: # snoop -i /var/tmp/optima0.txt | more 1 0.00000 AIOPTSVR -> 10.100.4.72 TCP D=1393 S=22 Push... (8 Replies)
Discussion started by: fretagi
8 Replies

3. Shell Programming and Scripting

snoop script in background

Hi I want to write a script for snoop which can do snoop for 30 min and then process should be killed automatically I am using below codes #!/usr/bin/ksh snoop -d igb0 -o /opt/temp/abc.pcap sleep 1500 kill -9 `ps -ef|grep -i snoop |grep -v grep|awk '{print $2}'` But process is not... (3 Replies)
Discussion started by: anish19
3 Replies

4. Shell Programming and Scripting

Parse snoop output

Hi all, Is it possible to create an script that parse an snoop output similar to the example above ? Each line is ended by "$" (set list in vi). as a result, I would like to print the output in only one line. can someone give me some tip ? Thanks a lot .:) l version="1.0" ... (5 Replies)
Discussion started by: robdcb
5 Replies

5. Solaris

Snoop perl script

Hi , I would like to write a perl script with the snoop command to capture packets from a specific IP address to a node (incoming packets) and packets from that node for the same session to another node and save the capture to a file. I would like my script to be able to read my IP all the time... (7 Replies)
Discussion started by: Pouchie1
7 Replies

6. Shell Programming and Scripting

Capture Shell Script Output To A File

Hi, I am running a shell script called dbProcess.sh which performs shutdown and startup of various Oracle instances we have.At the time of execution the script produces the following output to the command line window $./dbProcess.sh stop #### Run Details ###### Hostname : server-hop-1... (4 Replies)
Discussion started by: rajan_san
4 Replies

7. Shell Programming and Scripting

script to capture certain output

Hi All, I want to create a script that capture only Date & Time, Current CPU % usage, Disk % usage, Mem % usage and Top process based on this output; Data Collected: 05/17/08 17:19:49 Refresh Interval: 600 seconds GlancePlus Started/Reset: 05/17/08 08:19:45 B3692A GlancePlus... (18 Replies)
Discussion started by: fara_aris
18 Replies

8. Shell Programming and Scripting

Snoop Script

Hi, I want to write a script that checks an interface with the snoop command, if there is no traffic in 10 minutes on port 123 from the ip add 10.*.*.* it should send a e-mail.but i don't know how to start writing this script does anybody have an idea or an sample script that i can modifi. ... (2 Replies)
Discussion started by: tafil
2 Replies

9. UNIX for Dummies Questions & Answers

how to capture multicast packets using snoop

How do I use snoop command to capture multicast packets in the network? (1 Reply)
Discussion started by: caden312
1 Replies

10. Shell Programming and Scripting

Capture output from interactive script

I have written a menu driven script to walk users through bringing up and down an application process. Sometimes the user tells me the script does not work taking the application down, but he can't recall seeing an error message. Is there a way to capture std out and stderr out from an... (6 Replies)
Discussion started by: MizzGail
6 Replies
Login or Register to Ask a Question