Thank you zentara and salva for your answers.

Unfortunately, after messing with this all day, I wasn't able to get anything working from either one your posts. My thought now is to post the Net::SSH:Expect code that I've been using and I am trying to convert to Net::OpenSSH. Maybe this will help identify what I am trying to achieve, and the reasons behind it. So, here it is...

#!/usr/bin/perl use Net::SSH::Expect; my $ssh = Net::SSH::Expect->new ( host => "10.0.0.1", port => "22", user => "testuser", password => "testpassword", raw_pty => 1, timeout => '4', #log_file => "$TempLogFile" ); my $login_output = $ssh->login(); if ($login_output !~ /#/) { die "Login has failed. Login output was $login_output"; }; $ssh->exec("terminal width 512"); $ssh->exec("terminal length 0"); my @Output = $ssh->exec("sh run"); print "@Output\n"; $ssh->close();

Note that this code is using a username and password. If possible, I would rather use public key authentication.

Is this possible using the Net::OpenSSH Module (with maybe expect)? If so, how could I write it?

Thanks


In reply to Re: Net::OpenSSH multiple commands by mlebel
in thread Net::OpenSSH multiple commands by mlebel

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.