All,
I am writtting this script for a client that will transfer their files via SFTP and write a small log to their system. I would also like it to write a log on our server as well, other than just doing what I have, writting the date and the file transfered. What can I do to capture erros from SFTP so that if the transfer fails I can write it to the log file? Script is below:
Thanks for the help. Tim
#Here is my rules to keep me strict use strict; use Net::SFTP;
#Who am I and where am I going? my $user = 'user'; my $pass = 'password'; my $sftp; my $home = "/home/user/test.txt"; my $path = "/home/user/test.txt"; my $host = '0.0.0.0';
#Where the real action takes place...
$sftp = Net::SFTP->new($host, "user" => $user, "password" => $pass) or die "Can't login $!\n";
$sftp->put($home,$path) || die "Can't open $!\n";
# Writting log files for transfers # open LOGS, ">> cshareTransfer.log" or die "Can't open file, $!\n";
# Get my dates # my $date; my ($sec,$min,$hour,$mday,$mon,$year) = (localtime) [0,1,2,3,4,5]; $year=$year+1900; $mon=$mon+1; $date = sprintf("%02d%02d%02d", $year,$mon,$mday); # # Write my logs so I can track myself # print LOGS "Transfer date:$date, File transfered:$path\n"; close LOGS;
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>