Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

put file into another server

Status
Not open for further replies.

rozzay

Programmer
Jan 3, 2002
142
US
Morning,

I am trying to put a file from 1 server directory to another server directory. I keep getting the below error message I am not sure what i am missing. I apologize for the dumbness still trying to learn Perl.

Cannot open Local file /usr/local/cyclone/data/ZZAAFES/binaryout/test.txt: No such file or directory

===================================================
#!/usr/bin/perl

use File::Copy;
use File::Basename;

#DEFINE VARIABLES
my $now = localtime;
open

$dir = "///Hqdata01/sdmidata/VIALINK/IMFT/test.txt";
print "DIR name IS: $dir\n";
$path = "/usr/local/cyclone/data/ZZAAFES/binaryout/";
print "Path filename is: $path\n";
$file = basename($dir);

#INITIATES FTP CONNECTION TO CYCLONE AND WRITES VIALINK FILE FROM Hqdata01
ftpsub();
sub ftpsub {
use NET::FTP;
my $ftp;
$ftp = Net::FTP -> new("cyclone.aafes.com", Debug=> 1) || ((print REPORT "$now->ERROR:FTP HQDATA01 TO CYCLONE FAILED\n"), return(1));
$ftp->login("loginid","pwd") || ((print REPORT "$now->FTP REPORT failed\n"), return(1));
$ftp->cwd($path) || ((print REPORT "$now-> $path - Change path failed\n"), return(1));
print "Path is: $path\n";
print "Put file: $file\n";
#$ftp->put ($dir . $file) || ((print REPORT "$NOW-> $filename - Putting file failed\n"), return(1));
#$ftp->put ($dir . $path) || ((print REPORT "$NOW-> $filename - Putting file failed\n"), return(1));
$ftp->put ($path . $file) || ((print REPORT "$NOW-> $filename - Putting file failed\n"), return(1));
$ftp->close();
print Report "$now->FTP TO CYCLONE IMF COMPLETED\n";
return (0);
};

close REPORT;
exit;
 
what is open doing here?

my $now = localtime;
open

you have a few scalars that appear to be wrong:

$ftp->put ($path . $file) || ((print REPORT "$NOW-> $filename - Putting file failed\n"), return(1));

Looks like $NOW should be $now and $filename has never been defined.

print Report "$now->FTP TO CYCLONE IMF COMPLETED\n";

It looks like "Report" should be REPORT.


Fix those things and try again.




 
I apologize I was trying to keep the it short so i cut a few lines out. But below is the complete script. Per to your comment I did fix the $NOW to $now


#!/usr/bin/perl

use File::Copy;
use File::Basename;
#PERL SCRIPT TO PUT FILE FROM HQDAT01 TO CYCLONE BINARYOUT/PIMAAFESIMFT

#DEFINE VARIABLES
my $now = localtime;
open (REPORT, ">>//Hqdata01/sdmidata/VIALINK/LOG/IMFT_extract.log");
print REPORT "$now->GXS_IMFT_extract.pl script STARTED!\n";

$dir = "\\\\Hqdata01\\sdmidata\\VIALINK\\IMFT\\test.txt";
print "DIR name IS: $dir\n";
$path = "/usr/local/cyclone/data/ZZAAFES/binaryout/";
print "Path filename is: $path\n";
$file = basename($dir);
print "FILE IS $file\n";

#INITIATES FTP CONNECTION TO CYCLONE AND WRITES VIALINK FILE FROM Hqdata01
ftpsub();
sub ftpsub {
print REPORT "$now->FTP HQDATA01 CONNECT TO CYCLONE STARTED\n";
print "ftp started\n";
use NET::FTP;
my $ftp;
$ftp = Net::FTP -> new("cyclone.aafes.com", Debug=> 1) || ((print REPORT "$now->ERROR:FTP HQDATA01 TO CYCLONE FAILED\n"), return(1));
$ftp->login("loginid","pwd") || ((print REPORT "$now->FTP REPORT failed\n"), return(1));
$ftp->cwd($path) || ((print REPORT "$now-> $path - Change path failed\n"), return(1));
print "Path is: $path\n";
print "Put file: $file\n";
$ftp->put ($dir , $file) || ((print REPORT "$now-> $filename - Putting file failed\n"), return(1));
$ftp->close();
print REPORT "$now->FTP TO CYCLONE IMF COMPLETED\n";
return (0);
};

close REPORT;
exit;
 
I assume you are putting in the correct login and password info here?

$ftp->login("loginid","pwd")
 
yes this is just a sample but i do have print statements and log report that do track that I was able to login in successfully and change the to the correct folder path.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top