1

I'm using Net::SSH2 to run slow admin commands on remote hosts.

Perl 5.8.8 libssh2 1.2.2

I keep getting a strange "timeout" on channel exec. $chan->exec( $command );

The commands being executed are normally running up to an hour (60 min) with minimal output during execution.

Short commands work fine. Slow ones with minimal output return 1 after about one minute.

I have set the socket to blocking and set timeouts to 60 minutes and so on ... nothing helped.

Any ideas?

peitur
  • 121
  • 13

1 Answers1

1

Run the command using "nohup command &" in Net::SSH2, then keep the connection alive by checking on the state of the spawned program.

See the following thread for more information:

http://www.perlmonks.org/index.pl?node_id=868377

Horus
  • 1,169
  • 9
  • 13
  • I was hoping to solve this with libssh or worst case on the socket. The way the called application works, I can't rely on this kind of process monitoring. – peitur Apr 20 '11 at 06:28
  • It doesn't need to be state checking, as long as you are pushing something through the socket you should be fine, or you could modify the executed command to output something every few seconds, either with a thread or with a fork(), I'm just tossing stuff out there at this point. – Horus Apr 20 '11 at 15:33