I have recently installed the Net::SCP (ver 0.07) module within my server "Alpha". I then wrote a perl script which goes and puts files from server "Alpha" to "Beta". It works fine when run manually. Here's the script in it's entirety:
#!/usr/bin/perl use Net::SCP; $scp = Net::SCP->new ( "beta.kanja.gc.au", "guestUser"); $scp->cwd("/beta/path/router/files/") or die $scp->{errstr}; open(rtrList, "/alpha/path/list_of_files.lst"); while(<rtrList>) { chomp; $file = $_; $scp->put("$file") or die $scp->{errstr}; } close(rtrList);
Note: my $file scalar, in the code above, is the filename with its absolute path: /alpha/absolute/path/file1.cfg

Here's the problem...

When run as a cronjob, it fails once it gets within the while loop, specifically the last line of execution within loop: $scp->put. Yet I have nothing in my log file? Why? I then managed to find something in the unix mail addressed to me(root), which reads:
Your "cron" job on Alpha /alpha/script_path/fileXfr.pl > /tmp/fileXfr.log 2>$1 produced the following output: open3: exec of scp -pqB /alpha/absolute/path/file1.cfg guestUser@beta. +kanja.gc.au:/beta/path/router/files/file1.cfg failed at /usr/perl5/site_perl/5.6.1/Net/SCP.pm line 93
I have looked at line 93 in SCP.pm and I feel I'm in over my head at this point. Your advice would be much appreciated.

Thanks in advanced,

Papai

In reply to scp fails in cronjob - open3 error by papai

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.