Creating graphical ftp client with Perl using class NET:: FTP
I am creating a graphical ftp client with Perl using class NET:: FTP, and for that I want to try get function on an ftp server G6FTP Server. But I don't know how to create files on that server and how can I connect from my perl script? Though I found some examples that connects to a ftp site, but in the case of local server I must connect with the IP address domain or something like that? Do I need stp help?
Here is my code:
Code:
#!/usr/local/bin/perl
use Net::FTP;
my $server = '127.0.0.1';
my $source = 'Main log';
my $ftp = Net::FTP->new($server);
$ftp->cwd("/Logs & Reports");
$ftp->get("$source");
$ftp->quit;
exit 0;
Re: Creating graphical ftp client with Perl using class NET:: FTP
some correction in your code
Code:
#!/usr/bin/perl
use warnings;
use strict;
use Net::FTP;
my $ftp = Net::FTP->new("some.host.name", Debug => 0)
or die "Cannot connect to some.host.name: $@";
$ftp->login("anonymous",'-anonymous@')
or die "Cannot login ", $ftp->message;
$ftp->cwd("/pub")
or die "Cannot change working directory ", $ftp->message;
$ftp->get("that.file")
or die "get failed ", $ftp->message;
$ftp->quit;
Re: Creating graphical ftp client with Perl using class NET:: FTP
I did according to the documentation of Net:: FTP, but I want to know if the portion of the code is correct or not:
my $ftp = Net::FTP->new('127.0.0.1');
I mean to connect by IP address of FTP server in that way.
Re: Creating graphical ftp client with Perl using class NET:: FTP
Net:: FTP look's pretty, but is it possible to use it from a Linux computer to fetch a file (more precisely an archive) on a PC running on windows?
Quote:
but I want to know if the portion of the code is correct or not
yes, if there is a ftp server on this PC. If you are able, from your Linux console, to connect to FTP on your PC, then with Net:: FTP, you can.
Did you test?
Re: Creating graphical ftp client with Perl using class NET:: FTP
OK, I tested but I have a problem, the connection is refused.
Code:
#!/usr/bin/perl
use strict;
use warnings;
use Net::FTP;
my $ftp = Net::FTP->new("192.168.0.50")
or die "Cannot connect to '192.168.0.50': $@";
$ftp->login("login","mdp")
or die "Cannot login ", $ftp->message;
$ftp->cwd("path/linux")
or die "Cannot change working directory ", $ftp->message;
$ftp->get("path/windows/archive.tar.gz")
or die "get failed ", $ftp->message;
$ftp->quit;
And I have this error message:
Quote:
Can not connect to '192 .168.0.50 ': Net:: FTP: connect: Connection refused at ftp.pl line 6.
Hence it may come?
Re: Creating graphical ftp client with Perl using class NET:: FTP
Hello,
There is a free FTP client in Perl :
It's released under the GNU GPL license so you can use it or modify it,
don't hesitate if you have any questions or comments,
Regards
Re: Creating graphical ftp client with Perl using class NET:: FTP
Quote:
Originally Posted by
revy
Hello,
There is a free FTP client in Perl :
It's released under the GNU GPL license so you can use it or modify it,
don't hesitate if you have any questions or comments,
Regards
For info the script can be found on SourceForge, it's called "Perl FTP Client".
You can read the script from SourceForge, it can certainly help you understand how to use Net::FTP.