Is it possible to run code when an expect script it terminated?
Given the following example;
#!/usr/bin/expect
while { true } {
puts "I am alive"
sleep 5
}
puts "I am dead"
This will continuously print "I am alive". When I press CTRL+C to kill the script, how can I call a function (or similar) to print "I am dead" on the way out?
This link explains how to handle SIGINT in Expect. This is what you want to do in your code: