I am using the Net::SSH::Perl module to run commands on a remote linux server (located in the same LAN). It appears to me that I am having a timing problem. The relevant part of my code looks like this:
The execution time of the command on the remote server varies with what arguments are passed. For e.g, if DES encryption is required, it takes about 1 min and if RSA is used it takes 10 mins.my $cmd = Generate_Command($arg1,$arg2); $ssh->cmd($cmd); $cmd = Generate_Another_Command($arg1,$arg2); $ssh->cmd($cmd);
The problem I am facing is that perl seems to execute the next line of code without the first command over ssh running to completion. As a result, the second command over ssh fails (as it depends on the first). Is there a workaround for this problem? I tried implementing a solution with fork() where the SSH stuff runs in the child and the parent waits for it to complete, but this hasn't worked for me either. Can someone suggest an efficient method to wait for the command on the remote to server to return before moving on to the next line of code?
The command I run on the server is a shell script executes a few java classes. It looks something like this:
Thanks a lot,#! export CLASSPATH=/usr/local/classes/classes12.zip PATH=/usr/local/java/bin:$PATH export LD_LIBRARY_PATH=/usr/local/tonga/lib /usr/local/tonga/bin/javadb dbVersion $1
Thanks for your suggestions. I am working on the script now and will post any updates as soon as I find them.
In reply to How to hold execution of perl script while it runs command on remote machine by linuxfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |