Mass Deface
cwd() has the same affect of calling ->cwd()
without any arguments. Turn on Debug (I) and you will see what is
happening
$ftp = Net::FTP->new($host, Debug => 1);
$ftp->login;
$ftp->cwd("");
gives
Net::FTP=GLOB(0x82196d8)>>> CWD /
Net::FTP=GLOB(0x82196d8)<<< 250 CWD command successful.
=head2 I am behind a SOCKS firewall, but the Firewall option does not work ?
The Firewall option is only for support of one type of firewall. The type
supported is an ftp proxy.
To use Net::FTP, or any other module in the libnet distribution,
through a SOCKS firewall you must create a socks-ified perl executable
by compiling perl with the socks library.
=head2 I am behind an FTP proxy firewall, but cannot access machines outside ?
Net::FTP implements the most popular ftp proxy firewall approach. The scheme
implemented is that where you log in to the firewall with C
I have heard of one other type of firewall which requires a login to the
firewall with an account, then a second login with C. You can
still use Net::FTP to traverse these firewalls, but a more manual approach
must be taken, eg
$ftp = Net::FTP->new($firewall) or die $@;
$ftp->login($firewall_user, $firewall_passwd) or die $ftp->message;
$ftp->login($ext_user . '@' . $ext_host, $ext_passwd) or die $ftp->message.
=head2 My ftp proxy firewall does not listen on port 21
FTP servers usually listen on the same port number, port 21, as any other
FTP server. But there is no reason why this has to be the case.
If you pass a port number to Net::FTP then it assumes this is the port
number of the final destination. By default Net::FTP will always try
to connect to the firewall on port 21.
Net::FTP uses IO::Socket to open the connection and IO::Socket allows
the port number to be specified as part of the hostname. So this problem
can be resolved by either passing a Firewall option like C<"hostname:1234">
or by setting the C option in Net::Config to be a string
in in the same form.
=head2 Is it possible to change the file permissions of a file on an FTP server ?
The answer to this is "maybe". The FTP protocol does not specify a command to change
file permissions on a remote host. However many servers do allow you to run the
chmod command via the C command. This can be done with
$ftp->site('chmod','0775',$file);
=head2 I have seen scripts call a method message, but cannot find it documented ?
Net::FTP, like several other packages in libnet, inherits from Net::Cmd, so
all the methods described in Net::Cmd are also available on Net::FTP
objects.
=head2 Why does Net::FTP not implement mput and mget methods
The quick answer is because they are easy to implement yourself. The long
answer is that to write these in such a way that multiple platforms are
supported correctly would just require too much code. Below are
some examples how you can implement these yourself.
sub mput {
my($ftp,$pattern) = @_;
foreach my $file (glob($pattern)) {
$ftp->put($file) or warn $ftp->message;
}
}
sub mget {
my($ftp,$pattern) = @_;
foreach my $file ($ftp->ls($pattern)) {
$ftp->get($file) or warn $ftp->message;
}
}
=head1 Using Net::SMTP
=head2 Why can't the part of an Email address after the @ be used as the hostname ?
The part of an Email address which follows the @ is not necessarily a hostname,
it is a mail domain. To find the name of a host to connect for a mail domain
you need to do a DNS MX lookup
=head2 Why does Net::SMTP not do DNS MX lookups ?
Net::SMTP implements the SMTP protocol. The DNS MX lookup is not part
of this protocol.
=head2 The verify method always returns true ?
Well it may seem that way, but it does not. The verify method returns true
if the command succeeded. If you pass verify an address which the
server would normally have to forward to another machine, the command
will succeed with something like
252 Couldn't verify but will attempt delivery anyway
This command will fail only if you pass it an address in a domain
the server directly delivers for, and that address does not exist.
=head1 Debugging scripts
=head2 How can I debug my scripts that use Net::* modules ?
Most of the libnet client classes allow options to be passed to the
constructor, in most cases one option is called C. Passing
this option with a non-zero value will turn on a protocol trace, which
will be sent to STDERR. This trace can be useful to see what commands
are being sent to the remote server and what responses are being
received back.
#!/your/path/to/perl
use Net::FTP;
my $ftp = new Net::FTP($host, Debug => 1);
$ftp->login('gbarr','password');
$ftp->quit;
this script would output something like
Net::FTP: Net::FTP(2.22)
Net::FTP: Exporter
Net::FTP: Net::Cmd(2.0801)
Net::FTP: IO::Socket::INET
Net::FTP: IO::Socket(1.1603)
Net::FTP: IO::Handle(1.1504)
Net::FTP=GLOB(0x8152974)<<< 220 imagine FTP server (Version wu-2.4(5) Tue Jul 29 11:17:18 CDT 1997) ready.
Net::FTP=GLOB(0x8152974)>>> user gbarr
Net::FTP=GLOB(0x8152974)<<< 331 Password required for gbarr.
Net::FTP=GLOB(0x8152974)>>> PASS ....
Net::FTP=GLOB(0x8152974)<<< 230 User gbarr logged in. Access restrictions apply.
Net::FTP=GLOB(0x8152974)>>> QUIT
Net::FTP=GLOB(0x8152974)<<< 221 Goodbye.
The first few lines tell you the modules that Net::FTP uses and their versions,
this is useful data to me when a user reports a bug. The last seven lines
show the communication with the server. Each line has three parts. The first
part is the object itself, this is useful for separating the output
if you are using multiple objects. The second part is either C<<<<<> to
show data coming from the server or C<>>>>> to show data
going to the server. The remainder of the line is the command
being sent or response being received.
=head1 AUTHOR AND COPYRIGHT
Copyright (c) 1997 Graham Barr.
All rights reserved.