Results 1 to 3 of 3
I consideer myself somewhat dangerous when writing scripts so
be easy one me....
I have the following script:
#! /bin/sh
# File: sipfuzz
# Protos SIP Fuzzing tool.
#
# ...
- 01-10-2008 #1Just Joined!
- Join Date
- Oct 2006
- Posts
- 4
How to kill background job in a script?
I consideer myself somewhat dangerous when writing scripts so
be easy one me....
I have the following script:
#! /bin/sh
# File: sipfuzz
# Protos SIP Fuzzing tool.
#
# Run Protos on any SIP enabled appliance.
# See list of tests in PROTOS Test-Suite c07-sip.htm
#
if [ $# -ne 3 ] ; then
echo 1>&2 Usage: sipfuzz '"IP Address Under Test"' '"Start Test #"' '"Stop Test #"'
exit 127
fi
# Need a way to start wireshark or tcpdump here to capture
# all of the packets for the test. Need to save in a file
# that can be associated with the test(s) being run
tcpdump -i eth0 -w SIPfuzz$2TO$3 &
# Proper format:
# java -jar c07-sip-r2.jar -touri 8502@100.3.28.10 -start 630 -stop 822
java -jar c07-sip-r2.jar -touri $1 -start $2 -stop $3
# Not sure the tcpdump will always be job #1?
kill %1
The problem is killing the tcpdump command. I thought the "kill %1" would work but for whatever reason, it doesn't....
Any ideas how to stop the tcpdump process after the java code is completed?
Thanks.
Ray
- 01-10-2008 #2
Yes indeed. It comes from a friend called $!. $! stores the PID of the last executed program.
So we do the following instead:
Easy peasy.Code:#! /bin/sh # File: sipfuzz # Protos SIP Fuzzing tool. # # Run Protos on any SIP enabled appliance. # See list of tests in PROTOS Test-Suite c07-sip.htm # if [ $# -ne 3 ] ; then echo 1>&2 Usage: sipfuzz '"IP Address Under Test"' '"Start Test #"' '"Stop Test #"' exit 127 fi # Need a way to start wireshark or tcpdump here to capture # all of the packets for the test. Need to save in a file # that can be associated with the test(s) being run tcpdump -i eth0 -w SIPfuzz$2TO$3 & tcpdpid=$! # Proper format: # java -jar c07-sip-r2.jar -touri 8502@100.3.28.10 -start 630 -stop 822 java -jar c07-sip-r2.jar -touri $1 -start $2 -stop $3 kill $tcpdpid
DISTRO=Arch
Registered Linux User #388732
- 01-10-2008 #3Just Joined!
- Join Date
- Oct 2006
- Posts
- 4
Thanks. Piece of cake!


Reply With Quote