Instead of using Perl::Expect which causes the script to grow in scripting I have used NET::SCP:EXPECT for transfering data. When running my perl script uses this package I'm running into an unexpected issue after transferring the data. The part is that I'm trying to up/down load files to/from Cisco routers and switches. A normal ssh access looks like this:

myserver ~ >ssh user@1.2.3.4 TACACS+ Password: Router#exit Connection to 1.2.3.4 closed by remote host. Connection to 1.2.3.4 closed. myserver ~ >

The transfer of my files however are successful but after the completion of the transfer getting: "at /prod/perl5/5.22/modules/lib/perl5/Expect.pm line 760.closed by remote host." and then the script dies. I suspect of the 1st or 2nd line prompted back "Connection to 1.2.3.4 closed (by remote host)." from the router or session is causing this issue.

Is there a way round this?

sub anoc2server { ### Start the SCP my ($user, $passwd, $dstserver, $srcpathfile, $dstpathfile) = @_; my $scp = Net::SCP::Expect->new(host=>$dstserver, user=>$user, + password=>$passwd); {$scp->scp($srcpathfile,$dstpathfile);}} }

srcpathfile and dstpathfile are the full directory paths including the filename.

Frits

In reply to NET::SCP:EXPECT I'm running into an unexpected issue. by Frits

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.