releasing/cbrtools/perl/Net/libnetFAQ.pod
author jascui
Tue, 16 Nov 2010 15:54:07 +0800
changeset 682 2c32f186fa1f
parent 602 3145852acc89
permissions -rw-r--r--
Solving incorrect handling when processing ExportName=SymbolName@Ordinal syntax.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 1997 Graham Barr.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
libnetFAQ - libnet Frequently Asked Questions
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
=head2 Where to get this document
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
This document is distributed with the libnet distribution, and is also
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
available on the libnet web page at
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
    http://search.cpan.org/~gbarr/libnet/
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
=head2 How to contribute to this document
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
You may mail corrections, additions, and suggestions to me
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
gbarr@pobox.com.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
=head1 Author and Copyright Information
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
Copyright (c) 1997-1998 Graham Barr. All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
This document is free; you can redistribute it and/or modify it
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
under the terms of the Artistic License.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
=head2 Disclaimer
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
This information is offered in good faith and in the hope that it may
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
be of use, but is not guaranteed to be correct, up to date, or suitable
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
for any particular purpose whatsoever.  The authors accept no liability
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
in respect of this information or its use.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
=head1 Obtaining and installing libnet
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
=head2 What is libnet ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
libnet is a collection of perl5 modules which all related to network
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
programming. The majority of the modules available provided the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
client side of popular server-client protocols that are used in
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
the internet community.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
=head2 Which version of perl do I need ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
libnet has been know to work with versions of perl from 5.002 onwards. However
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
if your release of perl is prior to perl5.004 then you will need to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
obtain and install the IO distribution from CPAN. If you have perl5.004
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
or later then you will have the IO modules in your installation already,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
but CPAN may contain updates.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
=head2 What other modules do I need ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
The only modules you will need installed are the modules from the IO
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
distribution. If you have perl5.004 or later you will already have
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
these modules.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
=head2 What machines support libnet ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
libnet itself is an entirely perl-code distribution so it should work
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
on any machine that perl runs on. However IO may not work
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
with some machines and earlier releases of perl. But this
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
should not be the case with perl version 5.004 or later.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
=head2 Where can I get the latest libnet release
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
The latest libnet release is always on CPAN, you will find it
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
in 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
 http://www.cpan.org/modules/by-module/Net/
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
The latest release and information is also available on the libnet web page
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
at
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
 http://search.cpan.org/~gbarr/libnet/
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
=head1 Using Net::FTP
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
=head2 How do I download files from an FTP server ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
An example taken from an article posted to comp.lang.perl.misc
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
    #!/your/path/to/perl
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
    # a module making life easier
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
    use Net::FTP;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
    # for debuging: $ftp = Net::FTP->new('site','Debug',10);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
    # open a connection and log in!
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
    $ftp = Net::FTP->new('target_site.somewhere.xxx');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
    $ftp->login('username','password');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
    # set transfer mode to binary
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
    $ftp->binary();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
    # change the directory on the ftp site
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
    $ftp->cwd('/some/path/to/somewhere/');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
    foreach $name ('file1', 'file2', 'file3') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
    # get's arguments are in the following order:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
    # ftp server's filename
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
    # filename to save the transfer to on the local machine
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
    # can be simply used as get($name) if you want the same name
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
      $ftp->get($name,$name);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
    # ftp done!
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
    $ftp->quit;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
=head2 How do I transfer files in binary mode ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
To transfer files without <LF><CR> translation Net::FTP provides
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
the C<binary> method
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
    $ftp->binary;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
=head2 How can I get the size of a file on a remote FTP server ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
=head2 How can I get the modification time of a file on a remote FTP server ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
=head2 How can I change the permissions of a file on a remote server ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
The FTP protocol does not have a command for changing the permissions
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
of a file on the remote server. But some ftp servers may allow a chmod
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
command to be issued via a SITE command, eg
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
    $ftp->quot('site chmod 0777',$filename);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
But this is not guaranteed to work.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
=head2 Can I do a reget operation like the ftp command ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
=head2 How do I get a directory listing from an FTP server ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
=head2 Changing directory to "" does not fail ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
Passing an argument of "" to ->cwd() has the same affect of calling ->cwd()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
without any arguments. Turn on Debug (I<See below>) and you will see what is
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
happening
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
    $ftp = Net::FTP->new($host, Debug => 1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
    $ftp->login;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
    $ftp->cwd("");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
gives
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
    Net::FTP=GLOB(0x82196d8)>>> CWD /
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
    Net::FTP=GLOB(0x82196d8)<<< 250 CWD command successful.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
=head2 I am behind a SOCKS firewall, but the Firewall option does not work ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
The Firewall option is only for support of one type of firewall. The type
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
supported is an ftp proxy.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
To use Net::FTP, or any other module in the libnet distribution,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
through a SOCKS firewall you must create a socks-ified perl executable
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
by compiling perl with the socks library.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
=head2 I am behind an FTP proxy firewall, but cannot access machines outside ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
Net::FTP implements the most popular ftp proxy firewall approach. The scheme
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
implemented is that where you log in to the firewall with C<user@hostname>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
I have heard of one other type of firewall which requires a login to the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
firewall with an account, then a second login with C<user@hostname>. You can
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
still use Net::FTP to traverse these firewalls, but a more manual approach
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
must be taken, eg
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
    $ftp = Net::FTP->new($firewall) or die $@;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
    $ftp->login($firewall_user, $firewall_passwd) or die $ftp->message;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
    $ftp->login($ext_user . '@' . $ext_host, $ext_passwd) or die $ftp->message.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
=head2 My ftp proxy firewall does not listen on port 21
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
FTP servers usually listen on the same port number, port 21, as any other
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
FTP server. But there is no reason why this has to be the case.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
If you pass a port number to Net::FTP then it assumes this is the port
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
number of the final destination. By default Net::FTP will always try
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
to connect to the firewall on port 21.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
Net::FTP uses IO::Socket to open the connection and IO::Socket allows
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
the port number to be specified as part of the hostname. So this problem
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
can be resolved by either passing a Firewall option like C<"hostname:1234">
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
or by setting the C<ftp_firewall> option in Net::Config to be a string
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
in in the same form.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
=head2 Is it possible to change the file permissions of a file on an FTP server ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
The answer to this is "maybe". The FTP protocol does not specify a command to change
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
file permissions on a remote host. However many servers do allow you to run the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
chmod command via the C<SITE> command. This can be done with
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
  $ftp->site('chmod','0775',$file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
=head2 I have seen scripts call a method message, but cannot find it documented ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
Net::FTP, like several other packages in libnet, inherits from Net::Cmd, so
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
all the methods described in Net::Cmd are also available on Net::FTP
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
objects.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
=head2 Why does Net::FTP not implement mput and mget methods
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
The quick answer is because they are easy to implement yourself. The long
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
answer is that to write these in such a way that multiple platforms are
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
supported correctly would just require too much code. Below are
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
some examples how you can implement these yourself.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
sub mput {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
  my($ftp,$pattern) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
  foreach my $file (glob($pattern)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
    $ftp->put($file) or warn $ftp->message;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
sub mget {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
  my($ftp,$pattern) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
  foreach my $file ($ftp->ls($pattern)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
    $ftp->get($file) or warn $ftp->message;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
=head1 Using Net::SMTP
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
=head2 Why can't the part of an Email address after the @ be used as the hostname ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
The part of an Email address which follows the @ is not necessarily a hostname,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
it is a mail domain. To find the name of a host to connect for a mail domain
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
you need to do a DNS MX lookup
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
=head2 Why does Net::SMTP not do DNS MX lookups ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
Net::SMTP implements the SMTP protocol. The DNS MX lookup is not part
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
of this protocol.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
=head2 The verify method always returns true ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
Well it may seem that way, but it does not. The verify method returns true
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
if the command succeeded. If you pass verify an address which the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
server would normally have to forward to another machine, the command
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
will succeed with something like
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
    252 Couldn't verify <someone@there> but will attempt delivery anyway
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
This command will fail only if you pass it an address in a domain
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
the server directly delivers for, and that address does not exist.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
=head1 Debugging scripts
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
=head2 How can I debug my scripts that use Net::* modules ?
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
Most of the libnet client classes allow options to be passed to the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
constructor, in most cases one option is called C<Debug>. Passing
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
this option with a non-zero value will turn on a protocol trace, which
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
will be sent to STDERR. This trace can be useful to see what commands
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
are being sent to the remote server and what responses are being
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
received back.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
    #!/your/path/to/perl
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
    use Net::FTP;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
    my $ftp = new Net::FTP($host, Debug => 1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
    $ftp->login('gbarr','password');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
    $ftp->quit;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
this script would output something like
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
 Net::FTP: Net::FTP(2.22)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
 Net::FTP:   Exporter
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
 Net::FTP:   Net::Cmd(2.0801)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
 Net::FTP:   IO::Socket::INET
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
 Net::FTP:     IO::Socket(1.1603)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
 Net::FTP:       IO::Handle(1.1504)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
 Net::FTP=GLOB(0x8152974)<<< 220 imagine FTP server (Version wu-2.4(5) Tue Jul 29 11:17:18 CDT 1997) ready.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
 Net::FTP=GLOB(0x8152974)>>> user gbarr
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
 Net::FTP=GLOB(0x8152974)<<< 331 Password required for gbarr.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
 Net::FTP=GLOB(0x8152974)>>> PASS ....
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
 Net::FTP=GLOB(0x8152974)<<< 230 User gbarr logged in.  Access restrictions apply.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
 Net::FTP=GLOB(0x8152974)>>> QUIT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
 Net::FTP=GLOB(0x8152974)<<< 221 Goodbye.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
The first few lines tell you the modules that Net::FTP uses and their versions,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   294
this is useful data to me when a user reports a defect. The last seven lines
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   295
show the communication with the server. Each line has three parts. The first
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   296
part is the object itself, this is useful for separating the output
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   297
if you are using multiple objects. The second part is either C<<<<<> to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   298
show data coming from the server or C<&gt&gt&gt&gt> to show data
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   299
going to the server. The remainder of the line is the command
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   300
being sent or response being received.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   301
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   302
=head1 AUTHOR AND COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   303
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   304
Copyright (c) 1997 Graham Barr.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   305
All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   306
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   307
=for html <hr>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   308
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   309
I<$Id: //depot/libnet/Net/libnetFAQ.pod#6 $>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   310