I am running the following script to start a capture on a remote server and download the file afterwards. Currently I have to pause it with Ctrl+C and manually exit.
How can I replace the interact and define a trigger to kill the tcpdump or catch the Ctrl+C and pass it inside the remote server?
spawn ssh "$user_ssh\@$ssh_server"
expect {
"*password" { send "$pass\n"; exp_continue}
"root\@*" { }
timeout { puts "time out expecting password or bash"; exit 1 }
}
send "sudo tcpdump -i $intf -s0 -w $file -v\n";
interact
spawn scp "$user_ssh\@$ssh_server:$file" .
expect "password:"
send "$pass_ssh\n";
expect "100\%"