.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "LIBNETFAQ 1"
.TH LIBNETFAQ 1 "2002-11-24" "perl v5.8.0" "Perl Programmers Reference Guide"
.SH "NAME"
libnetFAQ \- libnet Frequently Asked Questions
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
.Sh "Where to get this document"
.IX Subsection "Where to get this document"
This document is distributed with the libnet distribution, and is also
available on the libnet web page at
.PP
.Vb 1
\& http://www.pobox.com/~gbarr/libnet/
.Ve
.Sh "How to contribute to this document"
.IX Subsection "How to contribute to this document"
You may mail corrections, additions, and suggestions to me
gbarr@pobox.com.
.SH "Author and Copyright Information"
.IX Header "Author and Copyright Information"
Copyright (c) 1997\-1998 Graham Barr. All rights reserved.
This document is free; you can redistribute it and/or modify it
under the terms of the Artistic License.
.Sh "Disclaimer"
.IX Subsection "Disclaimer"
This information is offered in good faith and in the hope that it may
be of use, but is not guaranteed to be correct, up to date, or suitable
for any particular purpose whatsoever. The authors accept no liability
in respect of this information or its use.
.SH "Obtaining and installing libnet"
.IX Header "Obtaining and installing libnet"
.Sh "What is libnet ?"
.IX Subsection "What is libnet ?"
libnet is a collection of perl5 modules which all related to network
programming. The majority of the modules available provided the
client side of popular server-client protocols that are used in
the internet community.
.Sh "Which version of perl do I need ?"
.IX Subsection "Which version of perl do I need ?"
libnet has been know to work with versions of perl from 5.002 onwards. However
if your release of perl is prior to perl5.004 then you will need to
obtain and install the \s-1IO\s0 distribution from \s-1CPAN\s0. If you have perl5.004
or later then you will have the \s-1IO\s0 modules in your installation already,
but \s-1CPAN\s0 may contain updates.
.Sh "What other modules do I need ?"
.IX Subsection "What other modules do I need ?"
The only modules you will need installed are the modules from the \s-1IO\s0
distribution. If you have perl5.004 or later you will already have
these modules.
.Sh "What machines support libnet ?"
.IX Subsection "What machines support libnet ?"
libnet itself is an entirely perl-code distribution so it should work
on any machine that perl runs on. However \s-1IO\s0 may not work
with some machines and earlier releases of perl. But this
should not be the case with perl version 5.004 or later.
.Sh "Where can I get the latest libnet release"
.IX Subsection "Where can I get the latest libnet release"
The latest libnet release is always on \s-1CPAN\s0, you will find it
in
.PP
.Vb 1
\& http://www.cpan.org/modules/by-module/Net/
.Ve
.PP
The latest release and information is also available on the libnet web page
at
.PP
.Vb 1
\& http://www.pobox.com/~gbarr/libnet/
.Ve
.SH "Using Net::FTP"
.IX Header "Using Net::FTP"
.Sh "How do I download files from an \s-1FTP\s0 server ?"
.IX Subsection "How do I download files from an FTP server ?"
An example taken from an article posted to comp.lang.perl.misc
.PP
.Vb 1
\& #!/your/path/to/perl
.Ve
.PP
.Vb 1
\& # a module making life easier
.Ve
.PP
.Vb 1
\& use Net::FTP;
.Ve
.PP
.Vb 2
\& # for debuging: $ftp = Net::FTP->new('site','Debug',10);
\& # open a connection and log in!
.Ve
.PP
.Vb 2
\& $ftp = Net::FTP->new('target_site.somewhere.xxx');
\& $ftp->login('username','password');
.Ve
.PP
.Vb 1
\& # set transfer mode to binary
.Ve
.PP
.Vb 1
\& $ftp->binary();
.Ve
.PP
.Vb 1
\& # change the directory on the ftp site
.Ve
.PP
.Vb 1
\& $ftp->cwd('/some/path/to/somewhere/');
.Ve
.PP
.Vb 1
\& foreach $name ('file1', 'file2', 'file3') {
.Ve
.PP
.Vb 4
\& # get's arguments are in the following order:
\& # ftp server's filename
\& # filename to save the transfer to on the local machine
\& # can be simply used as get($name) if you want the same name
.Ve
.PP
.Vb 2
\& $ftp->get($name,$name);
\& }
.Ve
.PP
.Vb 1
\& # ftp done!
.Ve
.PP
.Vb 1
\& $ftp->quit;
.Ve
.Sh "How do I transfer files in binary mode ?"
.IX Subsection "How do I transfer files in binary mode ?"
To transfer files without <\s-1LF\s0><\s-1CR\s0> translation Net::FTP provides
the \f(CW\*(C`binary\*(C'\fR method
.PP
.Vb 1
\& $ftp->binary;
.Ve
.Sh "How can I get the size of a file on a remote \s-1FTP\s0 server ?"
.IX Subsection "How can I get the size of a file on a remote FTP server ?"
.Sh "How can I get the modification time of a file on a remote \s-1FTP\s0 server ?"
.IX Subsection "How can I get the modification time of a file on a remote FTP server ?"
.Sh "How can I change the permissions of a file on a remote server ?"
.IX Subsection "How can I change the permissions of a file on a remote server ?"
The \s-1FTP\s0 protocol does not have a command for changing the permissions
of a file on the remote server. But some ftp servers may allow a chmod
command to be issued via a \s-1SITE\s0 command, eg
.PP
.Vb 1
\& $ftp->quot('site chmod 0777',$filename);
.Ve
.PP
But this is not guaranteed to work.
.Sh "Can I do a reget operation like the ftp command ?"
.IX Subsection "Can I do a reget operation like the ftp command ?"
.Sh "How do I get a directory listing from an \s-1FTP\s0 server ?"
.IX Subsection "How do I get a directory listing from an FTP server ?"
.ie n .Sh "Changing directory to """" does not fail ?"
.el .Sh "Changing directory to ``'' does not fail ?"
.IX Subsection "Changing directory to """" does not fail ?"
Passing an argument of "" to \->\fIcwd()\fR has the same affect of calling \->\fIcwd()\fR
without any arguments. Turn on Debug (\fISee below\fR) and you will see what is
happening
.PP
.Vb 3
\& $ftp = Net::FTP->new($host, Debug => 1);
\& $ftp->login;
\& $ftp->cwd("");
.Ve
.PP
gives
.PP
.Vb 2
\& Net::FTP=GLOB(0x82196d8)>>> CWD /
\& Net::FTP=GLOB(0x82196d8)<<< 250 CWD command successful.
.Ve
.Sh "I am behind a \s-1SOCKS\s0 firewall, but the Firewall option does not work ?"
.IX Subsection "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.
.PP
To use Net::FTP, or any other module in the libnet distribution,
through a \s-1SOCKS\s0 firewall you must create a socks-ified perl executable
by compiling perl with the socks library.
.Sh "I am behind an \s-1FTP\s0 proxy firewall, but cannot access machines outside ?"
.IX Subsection "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 \f(CW\*(C`user@hostname\*(C'\fR
.PP
I have heard of one other type of firewall which requires a login to the
firewall with an account, then a second login with \f(CW\*(C`user@hostname\*(C'\fR. You can
still use Net::FTP to traverse these firewalls, but a more manual approach
must be taken, eg
.PP
.Vb 3
\& $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.
.Ve
.Sh "My ftp proxy firewall does not listen on port 21"
.IX Subsection "My ftp proxy firewall does not listen on port 21"
\&\s-1FTP\s0 servers usually listen on the same port number, port 21, as any other
\&\s-1FTP\s0 server. But there is no reason why this has to be the case.
.PP
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.
.PP
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 \f(CW"hostname:1234"\fR
or by setting the \f(CW\*(C`ftp_firewall\*(C'\fR option in Net::Config to be a string
in in the same form.
.Sh "Is it possible to change the file permissions of a file on an \s-1FTP\s0 server ?"
.IX Subsection "Is it possible to change the file permissions of a file on an FTP server ?"
The answer to this is \*(L"maybe\*(R". The \s-1FTP\s0 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 \f(CW\*(C`SITE\*(C'\fR command. This can be done with
.PP
.Vb 1
\& $ftp->site('chmod','0775',$file);
.Ve
.Sh "I have seen scripts call a method message, but cannot find it documented ?"
.IX Subsection "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.
.Sh "Why does Net::FTP not implement mput and mget methods"
.IX Subsection "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.
.PP
sub mput {
my($ftp,$pattern) = \f(CW@_\fR;
foreach my \f(CW$file\fR (glob($pattern)) {
\f(CW$ftp\fR\->put($file) or warn \f(CW$ftp\fR\->message;
}
}
.PP
sub mget {
my($ftp,$pattern) = \f(CW@_\fR;
foreach my \f(CW$file\fR ($ftp\->ls($pattern)) {
\f(CW$ftp\fR\->get($file) or warn \f(CW$ftp\fR\->message;
}
}
.SH "Using Net::SMTP"
.IX Header "Using Net::SMTP"
.Sh "Why can't the part of an Email address after the @ be used as the hostname ?"
.IX Subsection "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 \s-1DNS\s0 \s-1MX\s0 lookup
.Sh "Why does Net::SMTP not do \s-1DNS\s0 \s-1MX\s0 lookups ?"
.IX Subsection "Why does Net::SMTP not do DNS MX lookups ?"
Net::SMTP implements the \s-1SMTP\s0 protocol. The \s-1DNS\s0 \s-1MX\s0 lookup is not part
of this protocol.
.Sh "The verify method always returns true ?"
.IX Subsection "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
.PP
.Vb 1
\& 252 Couldn't verify <someone@there> but will attempt delivery anyway
.Ve
.PP
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.
.SH "Debugging scripts"
.IX Header "Debugging scripts"
.Sh "How can I debug my scripts that use Net::* modules ?"
.IX Subsection "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 \f(CW\*(C`Debug\*(C'\fR. Passing
this option with a non-zero value will turn on a protocol trace, which
will be sent to \s-1STDERR\s0. This trace can be useful to see what commands
are being sent to the remote server and what responses are being
received back.
.PP
.Vb 1
\& #!/your/path/to/perl
.Ve
.PP
.Vb 1
\& use Net::FTP;
.Ve
.PP
.Vb 3
\& my $ftp = new Net::FTP($host, Debug => 1);
\& $ftp->login('gbarr','password');
\& $ftp->quit;
.Ve
.PP
this script would output something like
.PP
.Vb 6
\& 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)
.Ve
.PP
.Vb 7
\& 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.
.Ve
.PP
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 \f(CW\*(C`<<<<\*(C'\fR to
show data coming from the server or \f(CW\*(C`>>>>\*(C'\fR to show data
going to the server. The remainder of the line is the command
being sent or response being received.
.SH "AUTHOR AND COPYRIGHT"
.IX Header "AUTHOR AND COPYRIGHT"
Copyright (c) 1997 Graham Barr.
All rights reserved.
.PP
\&\fI$Id: //depot/libnet/Net/libnetFAQ.pod#5 $\fR
|