I run the following script to start the capture on a remote server and upload the file later. Currently, I have to pause it with Ctrl+ Cand exit manually.
How can I replace the interaction and define a trigger to kill tcpdump or catch Ctrl+ Cand send it to a 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\%"
To send a Ctrl+ C, do:
send \x03
To process incoming Ctrl+ C, do:
trap {your handler script here} SIGINT
, script ( ) ...
trap { send \x03 send_user "You pressed Ctrl+C\n" } SIGINT
! Ctrl + C ( ), , , , , .
Source: https://habr.com/ru/post/1541817/More articles:HQL error: c-sentence refers to two different sentence-elements - javaZ3 FP logic: creates an unexpected model - z3Many csv file writing tutorials have a mode set to "wb", why? - pythonCan I change the title in Tkinter? - pythonWhat about binary files on Windows? - pythonDifference between sessionTransacted and JmsTransactionManager - javaWriting to csv file in Python - pythonPrint values ββfrom a Fortran polymorphic derivative to GDB - fortranBeautiful soup: looking for a nested template? - pythonCreating Tkinter windows on taskbar - pythonAll Articles