I had a script like below
SSHOpen("10.4.5.6", "admin"); sub SSHOpen { my $ip_address = shift @_; my $ssh_login = shift @_; print STDERR "Opening SSH Connection to $ip_address (as $ssh_login +)\n"; my $ssh_reader = new FileHandle; my $ssh_writer = new FileHandle; my $cmd; if (defined($ssh_login) && $ssh_login ne "") { $cmd = "ssh -l $ssh_login -o 'Batchmode yes' $ip_address 2>&1" +; } else { $cmd = "ssh -o 'Batchmode yes' $ip_address 2>&1"; } print STDERR "\tRunning <$cmd>\n"; my $pid = open2($ssh_reader, $ssh_writer, $cmd); if ($pid <= 0) { print STDERR "\tSSH could not connect!\n"; close($ssh_reader) if defined($ssh_reader); close($ssh_writer) if defined($ssh_writer); return 1; } print STDERR "Open 2 Successfull with pid $pid \n"; $ssh_reader->autoflush(); $ssh_writer->autoflush(); print STDERR "SSH Reader and Write Autoflush \n"; my %ssh = (); $ssh{'object_type'} = "SSH"; $ssh{'reader'} = $ssh_reader; $ssh{'writer'} = $ssh_writer; # lets test the connection by sending a blank command print STDERR "\tSuccessful End of SSHOpen Funtion\n"; return (0, \%ssh); }
I am getting error sh: ssh : not found.. but i can see /usr/local/bin (where ssh residess) in $ENV{PATH}. what may be the issue? Can somebody helpme on this. Thanks in advance.

In reply to What is the path used by open2 by jayakumark

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.