#!/usr/bin/expect -f
spawn telnet 10.123.9.111
expect login {send username\r}
expect password {send password\r}
----Here i want to execute commands----
----Commands are stored in an array in example.pl script----
----All variables are global in perl script----
----After executing these commands, control should again transfer to the called perl script----
我怎么做到的?这是正确的方法吗?或者更好的方法吗?
答案 0 :(得分:0)
你需要从Perl驱动控制。我会从Perl动态编写expect脚本,在命令中编码从阵列运行。然后Perl可以执行expect脚本:
system "expect", "/tmp/newly_written_script.exp";
并在期望返回时继续处理。