I currently am running a script that, among other things, runs ssh commands on remote systems and processes the output. This script had been running fine as of July 8, but recently it appears to have just frozen. Looking at the log that the script prints to, it seems to have stopped at August 9 at ~4:15 AM while trying to scan a system via SSH. Running ps, I see the following:

root 15347 15339 15261 0.0 1.2 57984 48320 ? S Jul08 + 4:37 /usr/bin/perl /srv/www/cgi-bin//sysManager.pl /srv/www/cgi-b +in/ root 18773 18773 18773 0.0 0.2 12352 8576 pts/0 Ss+ Aug09 + 0:00 ssh -xMN -o NumberOfPasswordPrompts=1 -o PreferredAuthenti +cations=keyboard-interactive,password -S /root/.libnet-openssh-perl/h +scroot-[hostnameRemoved]-15347-95046 -o User=[usernameRemoved] -- [ho +stnameRemoved] root 18775 15339 15261 0.0 0.2 12096 8064 ? S Aug09 + 0:00 ssh -S /root/.libnet-openssh-perl/[usernameRemoved]-[hostn +ameRemoved]-15347-95046 -o User=[usernameRemoved] -- [hostnameRemoved +] [cmdRemoved]

The lines of code that equate to this scan are:

my $ssh = Net::OpenSSH->new($host, (user => $username, password => $pa +ssword, timeout=>30)); my($stdout, $stderr) = $ssh->capture2({timeout => 30}, $cmd);

Is there any way to debug what may have happened here and why it didn't time out, in the hopes that I can avoid this in the future or submit a bug report? I see it says in the Net::OpenSSH documentation regarding the "timeout" parameter that "As the Secure Shell protocol does not support signalling remote processes, in order to abort the remote process its input and output channels are closed. Unfortunately this aproach does not work in some cases." Is there another way to force this timeout? I've tried running the script again and didn't hit the problem this time, but am guessing it will happen again randomly later and don't want to have to manually restart the script every time it does.


In reply to Net::OpenSSH cmd not timing out as requested by Only1KW

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.