2012-08-13 7 views
-2
#!/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

您需要從Perl驅動控制。我會從Perl動態編寫期望腳本,編碼命令以從數組運行。然後Perl可以執行期望腳本:

system "expect", "/tmp/newly_written_script.exp"; 

並在期望返回時繼續進程。

相關問題