Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Need help on NET:FTP

by bh_perl (Monk)
on Apr 29, 2011 at 06:31 UTC ( [id://901931]=perlquestion: print w/replies, xml ) Need Help??

bh_perl has asked for the wisdom of the Perl Monks concerning the following question:


hi

Below is my script but when i run the script its not collect the input files from remote server. Why ?. Please help me

Run command Line:
./neax_ftp.pl -i 192.168.10.102 -u baharin -p baharin -r /home/baharin +/data/input -l /home/sysadmin/bh/input -f *.xml

The program code as below:
#!/usr/bin/perl use Net::FTP; use strict; use Getopt::Long; my ($username,$password,$ip,$remotedir,$localdir,$filename,$filemode) += (0,0,0,0,0,0,0); my ($ftp,$success); GetOptions ( "i=s" => \$ip, "u=s" => \$username, "p=s" => \$password, "r=s" => \$remotedir, "l=s" => \$localdir, "f=s" => \$filename, "m=s" => \$filemode ); my $log = "/home/sysadmin/bh/sys.log"; my $err; open (LOGS, ">> $log") or die ("Can't open $log\n"); #$ftp = Net::FTP->new("192.168.10.102") or die "Can't connect to 190.2 +54.14.34\n"; $ftp = Net::FTP->new($ip, Timeout=>240) or $err=1; print "LOGIN: $ip\n"; if ($err) { print (LOGS "Can't connect to $ip\n"); $ftp->quit; } $ftp->login("$username","$password") or $err=1; print "LOGIN: $username/$password\n"; if ($err) { print (LOGS "Can't login to $ip with $username, $password\n"); $ftp->quit; } $ftp->binary(); $ftp->cwd("$remotedir") or $err=1; print "LOGIN: $remotedir\n"; if ($err) { print (LOGS "Can't change to directory $remotedir\n"); $ftp->quit; } $ftp->get("$remotedir/$filename") or $err=1; print "LOGIN: DIR\n"; if ($err) { print (LOGS "Can't collect file $filename from dir $remotedir\ +n"); $ftp->quit; } $ftp->quit; close(LOGS);

Replies are listed 'Best First'.
Re: Need help on NET:FTP
by wind (Priest) on Apr 29, 2011 at 07:13 UTC

    What are the results when you run the script? Does it do anything?

    On a side note, you can group your options definition with defaults into one statement

    GetOptions ( "i=s" => \(my $ip = 0), "u=s" => \(my $username = 0), "p=s" => \(my $password = 0), "r=s" => \(my $remotedir = 0), "l=s" => \(my $localdir = 0), "f=s" => \(my $filename = 0), "m=s" => \(my $filemode = 0), );
      may be u r shell expands * in u r input. Give esaped input

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://901931]
Approved by Tanktalus
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-03-29 08:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found