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!

Perl FTP Script 1

Status
Not open for further replies.

bigkid123

ISP
Nov 5, 2002
18
US
I am new to Perl Scripting and have a problem with this script. I have a script that I run to generate a log file which contains the Month/Day within the filename and also the hostname of about 300 Unix Servers that the script is ran on. I am trying to use Net::Ftp in a script to pull this file back to another unix box in order to generate a report that includes all the files into 1 file. Here is the script that I am using and each time I run it it returns an error stating that it is unable to get the file.

Any help would be greatly appreciated
I am using AIS 4.2.1.0 on an F50
An example of the filename is tpcl0507@bst00223.

#!/usr/local/bin/perl -w

use Net::FTP;

$store = shift;

$user = "root";
@password = ("xxxxxxxx");
$date = `date +%m%d`;
$file = "tpcl$date"."\@$store";

$| = 1;

$ftp = Net::FTP->new($store);
$ftp->login($user, @password)
or die "Unable to connect to store \"$store\"";
$ftp->cwd("/tmp")
or die "Unable to change to the /tmp directory";
$ftp->binary();
$ftp->get("$file")
or die "Unable to get $file";
$ftp->quit();

 
can you retrieve the file by executing ftp from the command line?

try $ftp = Net::FTP->new($store , Debug => 3); ## from man page
 
Hi arnOld,

Thanks for the quick response. I can retrieve the file from the command line but I think since I am trying to have the file imput the hostname that I getting the file from is the problem. When I just ftp the file directly from a single location that works fine. Here is the output from using the Debug => 3 from your reply earlier. It looks as if it is splitting the filename into 2 parts and it cannot retrieve the file needed. Thanks again for any help that you can offer.

Net::FTP: Net::FTP(2.33)
Net::FTP: Exporter
Net::FTP: Net::Cmd(2.11)
Net::FTP: IO::Socket::INET
Net::FTP: IO::Socket(1.1603)
Net::FTP: IO::Handle(1.1504)

Net::FTP=GLOB(0x2019a530)<<< 220 bst00223 FTP server (Version 4.1 Tue Feb 16 14:
50:43 CST 1999) ready.
Net::FTP=GLOB(0x2019a530)>>> user root
Net::FTP=GLOB(0x2019a530)<<< 331 Password required for root.
Net::FTP=GLOB(0x2019a530)>>> PASS ....
Net::FTP=GLOB(0x2019a530)<<< 230 User root logged in.
Net::FTP=GLOB(0x2019a530)>>> CWD /tmp
Net::FTP=GLOB(0x2019a530)<<< 250 CWD command successful.
Net::FTP=GLOB(0x2019a530)>>> TYPE I
Net::FTP=GLOB(0x2019a530)<<< 200 Type set to I.
Net::FTP=GLOB(0x2019a530)>>> PORT 10,128,128,100,207,50
Net::FTP=GLOB(0x2019a530)<<< 200 PORT command successful.
Net::FTP=GLOB(0x2019a530)>>> RETR tpcl0508
@bst00223
Net::FTP=GLOB(0x2019a530)<<< 550 tpcl0508: A file or directory in the path name
does not exist.
Unable to get tpcl0508
@bst00223 at ./get_file line 20.
Net::FTP=GLOB(0x2019a530)>>> QUIT
Net::FTP=GLOB(0x2019a530)<<< 500 '@BST00223': command not understood.
 
Thanks So much for you help arn0ld, it worked like a charm!!! Much Thanks goes to you and your advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top