Perl Expect - How to control timeout on the target machine

I am new to Perl. I use the perl wait module to run on a remote system. Execute the set of commands there one by one using the send module (for example, $ exp-> send ("my command as the line goes here \ n"). The problem is that the commands that I execute take some time to process. the command shuts down the remote machine, and I return to the invitation of my machine computer. Could you help me deal with this.?

I've got one more question. I have a command that returns 2 values ​​after execution (let's say I'm printing for two values ​​on a remote machine). I want to write these 2 values ​​and pass the following command as an argument using the send module. How to do it.

Help me with this problem.

Thank.

I just found out about the wait module. There is an undef option that can be used with expectation like $ exp-> expect (undef). It will wait forever, and all teams will complete processing. But the problem is that it does not return control to the host machine. There is another option for using expect with eof, which will wait for it to meet eof and then return to the host computer. Although I do not know exactly how to use it. The elegant solution I found is to use ssh to run commands on a remote machine, and not to use expectations, in which case we do not need to deal with timeouts. :)

+3
source share
1 answer

I just found out about the wait module. There is an undef option that can be used with expectation like $ exp-> expect (undef). It will wait forever, and all teams will complete processing. But the problem is that it does not return control to the host machine. There is another option for using expect with eof, which will wait for it to meet eof and then return to the host computer. Although I do not know exactly how to use it. The elegant solution I found is to use ssh to run commands on a remote machine, and not to use expectations, in which case we do not need to deal with timeouts. :)

+1
source

Source: https://habr.com/ru/post/1752121/


All Articles