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!

FTP Script Help

Status
Not open for further replies.

bigkid123

ISP
Nov 5, 2002
18
US
Hi All,

I have created an ftp script to pull a file to one of our Unix Servers from our Unix Hosts. When I run the script I receive several errors and not sure why it is not running correctly. Can someone look at the script and tell me what could be wrong. Thanks so much.

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

use Net::FTP;

$store = shift;

$user = "root";
@password=&get_pass;
$date = `date +%m%d`;
chomp $date;
$dir = "/home/b088/ISP/daniel";
$file = "get_file2";
$local = "$dir/$file";
$remote = "/tmp/$file";

$| = 1;

$ftp = Net::FTP->new($store, Debug => 3);
$ftp->login($user, @password);
$ftp->binary();
$ftp->put($local, $remote);
$ftp->quit();
sub get_pass {
open (FH, "/home/b088/ISP/pass.txt") || die "can't open file $!";
@pass=<FH>;
close FH;
return @pass;
}



This is the output of the Debug ------

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(0x2017bdc8)<<< 220 bst00223 FTP server (Version 4.1 Tue Feb 16 14:
50:43 CST 1999) ready.
Net::FTP=GLOB(0x2017bdc8)>>> user root
Net::FTP=GLOB(0x2017bdc8)<<< 331 Password required for root.
Net::FTP=GLOB(0x2017bdc8)>>> PASS ....
Net::FTP=GLOB(0x2017bdc8)<<< 230 User root logged in.
Net::FTP=GLOB(0x2017bdc8)>>> TYPE I
Net::FTP=GLOB(0x2017bdc8)<<< 500 '': command not understood.
Net::FTP=GLOB(0x2017bdc8)>>> PORT 10,128,128,100,190,86
Net::FTP=GLOB(0x2017bdc8)<<< 200 Type set to I.
Net::FTP=GLOB(0x2017bdc8)>>> STOR /tmp/get_file2
Net::FTP=GLOB(0x2017bdc8)<<< 200 PORT command successful.
Net::FTP=GLOB(0x2017bdc8)>>> QUIT
Net::FTP=GLOB(0x2017bdc8)<<< 425 No data connection



Thanks Again!!!
 
Why @password? It's just a string so $password would be the normal idiom. There's certainly something getting out of kilter immediately after the password is passed, so I'd look at the get_pass function and make sure it returns a scalar, then assign it to a scalar rather than a list.

Yours,


fish

&quot;As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.&quot;
--Maurice Wilkes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top