-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----

どうすれば作れますか?これは正しい方法ですか?または、これを行うためのより良い方法はありますか?

4

1 に答える 1

0

Perl から制御を駆動する必要があります。配列から実行するコマンドをコーディングして、Perl から動的に Expect スクリプトを作成します。次に、Perl は expect スクリプトを実行できます。

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

戻りが予想されるときに処理を続行します。

于 2012-08-13T16:41:15.337 に答える