If you just need to connect and run a script, consider using the command-line SSH via the Expect module. I've found that quite helpful. Something like:

use strict; use warnings; use Expect; my $login = "xxx"; my $pass = "xxx2"; my $test_dir = "/foo/bar/"; my $cmd = "if [ -d $test_dir ]; then echo DIR_EXIST:1; else echo DIR_E +XIST:0; fi"; my $timeout = 30; my $ex = Expect->new('ssh','-t',"$login\@hostname",$cmd); # the -t fo +rces TTY allocation, helpful for Expect! $ex->expect( $timeout, [ qr/password:\s*$/i => sub { $ex->send($pass,"\n"); return 1; } ] +, [ timeout => sub { warn "Timeout waiting for password prompt"; ret +urn 1; } ], ); $ex->expect ( $timeout, [ qr/DIR_EXIST:\d/ => sub { print "Result: ",$ex->match(); } ], );

I've used this approach to do remote password-resets, user deletes, software installation, &c. It's a bit more code, but you get a lot more control.

<radiant.matrix>
Ramblings and references
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet

In reply to Re: Net::SSH::Perl and SSH protocols by radiantmatrix
in thread Net::SSH::Perl and SSH protocols by xorl

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.