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?

Était-ce utile?

La solution

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

exec kill $killPID
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top