I am using Expect to automate VoIP calls for quality measurements.
My script is calling another VoIP client for a given amount of times. Before the calls should be handled, tcpdump should sniff all the packets. While tcpdump occupies the terminal, the VoIP client can't be spawned afterwards. My script essentially looks like this:
set count [lindex $argv 0] //amount of calls that the VoIP should do
spawn tcpdump -i eth2 -s 0 -w dump1.pcap &
for {set i 1} {$i <= $count} {incr i 1} {
spawn ./pjsua --config-file=config.txt //starting VoIP client
expect "Make call: "
send "sip:[email protected]\r" //starting the VoIP call
sleep 30
send "h\r" //stopping the call
send "q\r" //closing the VoIP client
close //closing the spawned process
}
interact
I thought the & operator behind the tcpdump spawn spawns it in the background. However I get the error message:
send: spawn id exp7 not open
while executing
"send "\r""
invoked from within
"for {set i 1} {$i <= $count} {incr i 1} {
spawn ./pjsua --config-file=config.txt"
How can I capture the packets in the background with tcpdump and at the same time start the other process and do the VoIP calls?