2012-08-13 3 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에서 expect 스크립트를 동적으로 작성하고 배열에서 실행하는 명령을 코딩합니다. 그러면 Perl은 expect 스크립트를 실행할 수 있습니다.

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

예상대로 돌아 오면 프로세스가 계속됩니다.

관련 문제