J
jac
There's this script that suppose to tranfer files..
Weird this is when executed, sometimes its transfering, sometimes its
not.
Could someone help me please? have a look at the script and point me
where the wrong part is? thanks plenty!
#!/usr/bin/perl
use Net::FTP;
require "find.pl";
$hostname = "10.1.1.1"; # Hostname or IP address
$username = "someon"; # Ftp user name
$password = "xxxxxxx"; # Ftp password
$LocalBase = "/path/to/local/files/to/transfer"; #
location of the log directories
$RemotePath = "/path/to/destination"; # where to put archive file on
ftp server
$ArchFile = "log.tar"; # name of archive file
$TAR="/usr/sbin/tar";
$GZIP="/appl/util/gzip";
&find($LocalBase);
if (@FileList > 0)
{ &TransferFiles; }
else
{ $ErrorMsg = "There were not any files to transport at this time"; }
##########################
# TransferFiles()
##########################
sub TransferFiles
{
local ($File, $Goodxfr, $Cnt);
# Initialize variables to zero
$Goodxfr = 0;
$Cnt = 0;
# Change to the Base directory where the log files are written to #
chdir($LocalBase);
##########################
# FtpFiles()
##########################
sub FtpFiles
{
$ftp = Net::FTP->new($hostname, Debug => 0);
$ftp->login($username, $password) ||
&FtpErr ("ftp->login: Please check username and password\n");
$ftp->binary;
$ftp->cwd($RemotePath) ||
&FtpErr("ftp->cwd: Not able to change to $RemotePath\n");
$ftp->put("$DestLocalBase/$ArchFile.gz")||
&FtpErr("ftp->put: Failed transfering
$DestLocalBase/$ArchFile.gz\n");
##########################
# wanted()
##########################
sub wanted
{ # True if file exists and is graeter than the time period
if ( -f $name && -M _ > $TimePeriod )
{
$Name = substr($name,$BaseStrip,); # strips off the local base
directory
push(@FileList,$Name);
# $FileSize{$Name} = (stat($name))[7];
}
}
Weird this is when executed, sometimes its transfering, sometimes its
not.
Could someone help me please? have a look at the script and point me
where the wrong part is? thanks plenty!
#!/usr/bin/perl
use Net::FTP;
require "find.pl";
$hostname = "10.1.1.1"; # Hostname or IP address
$username = "someon"; # Ftp user name
$password = "xxxxxxx"; # Ftp password
$LocalBase = "/path/to/local/files/to/transfer"; #
location of the log directories
$RemotePath = "/path/to/destination"; # where to put archive file on
ftp server
$ArchFile = "log.tar"; # name of archive file
$TAR="/usr/sbin/tar";
$GZIP="/appl/util/gzip";
&find($LocalBase);
if (@FileList > 0)
{ &TransferFiles; }
else
{ $ErrorMsg = "There were not any files to transport at this time"; }
##########################
# TransferFiles()
##########################
sub TransferFiles
{
local ($File, $Goodxfr, $Cnt);
# Initialize variables to zero
$Goodxfr = 0;
$Cnt = 0;
# Change to the Base directory where the log files are written to #
chdir($LocalBase);
##########################
# FtpFiles()
##########################
sub FtpFiles
{
$ftp = Net::FTP->new($hostname, Debug => 0);
$ftp->login($username, $password) ||
&FtpErr ("ftp->login: Please check username and password\n");
$ftp->binary;
$ftp->cwd($RemotePath) ||
&FtpErr("ftp->cwd: Not able to change to $RemotePath\n");
$ftp->put("$DestLocalBase/$ArchFile.gz")||
&FtpErr("ftp->put: Failed transfering
$DestLocalBase/$ArchFile.gz\n");
##########################
# wanted()
##########################
sub wanted
{ # True if file exists and is graeter than the time period
if ( -f $name && -M _ > $TimePeriod )
{
$Name = substr($name,$BaseStrip,); # strips off the local base
directory
push(@FileList,$Name);
# $FileSize{$Name} = (stat($name))[7];
}
}