本文介绍了从Expect脚本运行本地命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在expect
脚本中的某个时间终止本地后台进程.考虑示例脚本:
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
我使用要杀死的本地进程的ID作为第一个参数运行此脚本.如何在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?
推荐答案
要在不需要交互的本地计算机上运行命令,请执行以下操作:
To run a command on the local machine that requires no interaction, do:
exec kill $killPID
这篇关于从Expect脚本运行本地命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!