xpect是一个免费的编程工具语言,用来实现自动和交互式任务进行通信,而无需人的干预。Expect的作者Don Libes在1990年开始编写Expect时对Expect做有如下定义:Expect是一个用来实现自动交互功能的软件套件(Expect [is a] software suite for automating interactive tools)。使用它系统管理员的可以创建脚本用来实现对命令或程序提供输入,而这些命令和程序是期望从终端(terminal)得到输入,一般来说这些输入都需
perl写expect脚本, Expect and using Expect with PERL. EXPECT: A TCL based Toolkit for Automating Interactive Tasks. Leveraging the task specific capabilities of Expect with the power and flexibility of PERL.
首先创建一个expect脚本ssh_expect,文件内容如下:
#!/usr/bin/expect -f
set hostname [lindex $argv 0]
set user [lindex $argv 1]
set passwd [lindex $argv 2]
set timeout 30
set force_conservative 1
if {$force_conservative} {
set send_slow {128 .1}
}
spawn ssh $user$h