So I'm trying to automate the transfer of some files between two linux boxen. My very simple script:
#!/usr/bin/perl use strict; use Net::SCP::Expect; my $user = "xferusr"; my $password = "xxxxxxxx"; my $server = "server123.internal"; my $remotedir = "/var/www/html/reports/2009"; my $filelocation = "/opt/work/reports/2009/"; print "Login...Starting scp..."; my $scpe = Net::SCP::Expect->new(host=>$server, user=>$user, password= +>$password, recursive=>'1'); print "\nFILELOCATION:" . $filelocation . "*\n"; print "REMOTEDIR: " . $remotedir . "\n"; $scpe->scp($filelocation . '*', $remotedir); print "SCP complete\n";
It dies with the error:
Error: last line returned was: opt/work/reports/2009/*: No such file or director at /usr/lib/perl5/site_perl/5.8.0/Expect.pm line 760
If I set verbose I get:
Executing: program /usr/bin/ssh host server123.internal, user ftpusr, command scp -v -r -t /var/www/html/stats_intra/2008 OpenSSH_3.6.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090701f xferusr@server123.internal's scp exited with non-success state: 256 at ./test_scp.pl line 19
If from the command line I do:
scp /opt/work/reports/2009/* xferusr@server123.internal:/var/www/html/ +reports/2009
It works just wonderfully. So I'm guessing I'm doing something wrong with Perl.

It appears from that first error message that the "/" at the beginning of the path was stripped off. I'm not sure why or how to fix that, or if this is just some weirdness with the error messages.

Can anyone help me figure this out?

Thanks in advance.


In reply to Problem with Net::SCP::Expect 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.