Question

I am trying to kill a local background process at a certain point in an expect script. Consider the sample script:

#! /usr/bin/expect
set killPID [lindex $argv 0];
set timeout 1
spawn ftp ftp.ftp.com
expect "Name"
send "Username\r"
expect "Password:"
send "xxxxxx\r"
expect "ftp>"
send_user "Killing local process id: $killPID\n"
interact

I run this script with the id of a local process that I want to kill as first argument. How can I kill the process just before the interact command?

Was it helpful?

Solution

To run a command on the local machine that requires no interaction, do:

exec kill $killPID
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top