Interesting! Thank you.

I will keep that in mind. I will first experiment with a simple $ssh->check_master

Let’s say that I created a master connection this way: my $ssh = Net::OpenSSH->new(...);

Before calling a slave ssh command with open3 or capture, I will test $ssh to check if it is still connected or not, like:
$ssh = Net::OpenSSH->new(...) unless ($ssh->check_master); $ssh->capture(...);

I will see how light or heavy on CPU this check_master function is.
EDIT: no errors and the script works fine. Killed the ssh process on the remote device to test and...
The script works, but not as expected. Seems that an ssh connection is recreated allowing the slave command to be run, but there is no more master ssh connection sticking. After first disconnect event, it reconnects each time instead of staying connected like the first time.

In reply to Re^2: Net::OpenSSH reconnect master if conn. closed by Bolemo
in thread Net::OpenSSH reconnect master if conn. closed by Bolemo

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.