I know the answer must be right in front of me, but I just don't see
it...

I wrote a script that looks for files and then sends them to a remote
SFTP server:

<code>
#!/usr/bin/perl -w
use strict;
use Net::SFTP;
use Logit;      # this is a homegrown function that takes a filename and
a line
                # of text to write to the file.

my $debug      = 1;
my $server     = "usmlrh03";     
my %sftp_args  = ( user     => 'my_user',
                   password => 'my_passwd',
                   debug    => $debug);


# Check for the presence of datafiles
my @datafiles = <foo.*>;

if ([EMAIL PROTECTED]) {
        logit('mylog.log', "No datafiles found");
        die "No datafiles";
};

my $sftp = Net::SFTP -> new($server, %sftp_args) or do {
        logit('mylog.log', "Can't connect to $server via SFTP");
        die "Can't connect to $server via SFTP";
};

my $rc;
for (@datafiles) {

        logit('mylog.log', "Putting file: $_");

        $rc = $sftp -> put($_);

        logit('mylog.log', "Put to $server via SFTP: rc=$rc");
}
exit;
#logit('mylog.log', "@datafiles: sent successfully");
#unlink $dotdone   or logit('mylog.log', "Unable to delete $dotdone"); 
#unlink @datafiles or logit('mylog.log', "Unable to delete @datafiles");


</code>

When I run this I get: 

Use of uninitialized value in concatenation (.) at
/usr/lib/perl5/site_perl/5.6.0/Net/SFTP.pm line 215.
usmlrh04: sftp: Sent SSH2_FXP_OPEN I:0 P:
Couldn't get handle: No such file or directory at
/usr/lib/perl5/site_perl/5.6.0/Net/SFTP.pm line 166.
usmlrh04: sftp: Sent message SSH2_FXP_WRITE I:1 O:0
Couldn't write to remote file: Failure at
/usr/lib/perl5/site_perl/5.6.0/Net/SFTP.pm line 261.
usmlrh04: sftp: Sent message T:4 I:2
Couldn't close file: Failure at
/usr/lib/perl5/site_perl/5.6.0/Net/SFTP.pm line 201.
Use of uninitialized value in concatenation (.) at ./my_sftp.pl line 37.

But there definitely is a file in the current directory called foo.csv.
I tried specifying the full path, ie, /home/user/foo.csv, but I got the
same results!

BTW I don't think this should matter, but this is running between two
(old) RH linux boxes.

If anyone can shed any light on this it would be much appreciated!
TIA

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to