html tool

2020年11月16日星期一

tcl-expect

 https://www.cnblogs.com/operationhome/p/9154055.html

yum install expect

 

使用 -d 选项:显示调试信息。

  示例脚本:

[root@localhost shell]# cat ssh.exp 
#!/usr/bin/expect -d
set timeout 30
spawn ssh-copy-id 192.168.123.218
expect {
"*yes/no" {send "yes\r"; exp_continue}
"password:" {send "123456\r"}
}
expect eof

  当我运行它 的时候,显示的信息(主要信息是加粗字体):

[popexizhi: 运行命令是expect ssh.exp ,这里的expect 与bash是并列的可选脚本执行器,不同语言]

expect version 5.45
argv[0] = /usr/bin/expect  argv[1] = -d  argv[2] = ./ssh.exp  
set argc 0
set argv0 "./ssh.exp"
set argv ""
executing commands from command file ./ssh.exp
spawn ssh-copy-id 192.168.123.218
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {130244}

没有评论:

发表评论