I have observed that the script hangs rarely
That indicates a bug somewhere. Use strace or some similar tool to discover what every component is doing. Your Java application or the wrapper may be waiting for something.

You can also enable debugging on Net::OpenSSH to see what is happening at the perl level:

$Net::OpenSSH::debug = -1;

are bash scripts faster when it comes to execution than its perl counterpart?

Perl code is usually faster than shell code. On scripts that invoke external commands, there is usually no difference between the two.

If your Perl script is slower it probably means that it is doing things in a different way.

In some cases, I also notice that a bash script prints messages that my perl script doesn’t.

Net::OpenSSH provides you several methods to redirect or capture the stdio streams of the remote process. You have to pick the ones that you need.

For instance, I had an issue where deployment was not happening on machine A. On investigation, I came to know that Java was not deployed. This I came to know when I logged into machine A and ran the bash script that my perl script was calling. I thought of triggering the same bash script using another bash script remotely from the same machine where my perl script was. I did see the Java missing message. Why is it so? Why is my perl script unable to capture the error message despite using ‘$ssh->error’ in my script?

That means that your wrapper script is hiding it. $ssh->error returns an error code when the remote command exits with a non zero value.


In reply to Re: Perl (Net::SSH::Perl) script sometimes hangs while running remote command but shell script works by salva
in thread Perl (Net::SSH::Perl) script sometimes hangs while running remote command but shell script works by Technext

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.