Run local command from expect script

青春壹個敷衍的年華 提交于 2019-12-13 01:23:40

问题


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?


回答1:


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

exec kill $killPID


来源:https://stackoverflow.com/questions/22911026/run-local-command-from-expect-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!