Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / man / man3 / Net::libnetFAQ.3
CommitLineData
920dae64
AT
1.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "Net::libnetFAQ 3"
132.TH Net::libnetFAQ 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide"
133.SH "NAME"
134libnetFAQ \- libnet Frequently Asked Questions
135.SH "DESCRIPTION"
136.IX Header "DESCRIPTION"
137.Sh "Where to get this document"
138.IX Subsection "Where to get this document"
139This document is distributed with the libnet distribution, and is also
140available on the libnet web page at
141.PP
142.Vb 1
143\& http://search.cpan.org/~gbarr/libnet/
144.Ve
145.Sh "How to contribute to this document"
146.IX Subsection "How to contribute to this document"
147You may mail corrections, additions, and suggestions to me
148gbarr@pobox.com.
149.SH "Author and Copyright Information"
150.IX Header "Author and Copyright Information"
151Copyright (c) 1997\-1998 Graham Barr. All rights reserved.
152This document is free; you can redistribute it and/or modify it
153under the terms of the Artistic License.
154.Sh "Disclaimer"
155.IX Subsection "Disclaimer"
156This information is offered in good faith and in the hope that it may
157be of use, but is not guaranteed to be correct, up to date, or suitable
158for any particular purpose whatsoever. The authors accept no liability
159in respect of this information or its use.
160.SH "Obtaining and installing libnet"
161.IX Header "Obtaining and installing libnet"
162.Sh "What is libnet ?"
163.IX Subsection "What is libnet ?"
164libnet is a collection of perl5 modules which all related to network
165programming. The majority of the modules available provided the
166client side of popular server-client protocols that are used in
167the internet community.
168.Sh "Which version of perl do I need ?"
169.IX Subsection "Which version of perl do I need ?"
170libnet has been know to work with versions of perl from 5.002 onwards. However
171if your release of perl is prior to perl5.004 then you will need to
172obtain and install the \s-1IO\s0 distribution from \s-1CPAN\s0. If you have perl5.004
173or later then you will have the \s-1IO\s0 modules in your installation already,
174but \s-1CPAN\s0 may contain updates.
175.Sh "What other modules do I need ?"
176.IX Subsection "What other modules do I need ?"
177The only modules you will need installed are the modules from the \s-1IO\s0
178distribution. If you have perl5.004 or later you will already have
179these modules.
180.Sh "What machines support libnet ?"
181.IX Subsection "What machines support libnet ?"
182libnet itself is an entirely perl-code distribution so it should work
183on any machine that perl runs on. However \s-1IO\s0 may not work
184with some machines and earlier releases of perl. But this
185should not be the case with perl version 5.004 or later.
186.Sh "Where can I get the latest libnet release"
187.IX Subsection "Where can I get the latest libnet release"
188The latest libnet release is always on \s-1CPAN\s0, you will find it
189in
190.PP
191.Vb 1
192\& http://www.cpan.org/modules/by-module/Net/
193.Ve
194.PP
195The latest release and information is also available on the libnet web page
196at
197.PP
198.Vb 1
199\& http://search.cpan.org/~gbarr/libnet/
200.Ve
201.SH "Using Net::FTP"
202.IX Header "Using Net::FTP"
203.Sh "How do I download files from an \s-1FTP\s0 server ?"
204.IX Subsection "How do I download files from an FTP server ?"
205An example taken from an article posted to comp.lang.perl.misc
206.PP
207.Vb 1
208\& #!/your/path/to/perl
209.Ve
210.PP
211.Vb 1
212\& # a module making life easier
213.Ve
214.PP
215.Vb 1
216\& use Net::FTP;
217.Ve
218.PP
219.Vb 2
220\& # for debuging: $ftp = Net::FTP->new('site','Debug',10);
221\& # open a connection and log in!
222.Ve
223.PP
224.Vb 2
225\& $ftp = Net::FTP->new('target_site.somewhere.xxx');
226\& $ftp->login('username','password');
227.Ve
228.PP
229.Vb 1
230\& # set transfer mode to binary
231.Ve
232.PP
233.Vb 1
234\& $ftp->binary();
235.Ve
236.PP
237.Vb 1
238\& # change the directory on the ftp site
239.Ve
240.PP
241.Vb 1
242\& $ftp->cwd('/some/path/to/somewhere/');
243.Ve
244.PP
245.Vb 1
246\& foreach $name ('file1', 'file2', 'file3') {
247.Ve
248.PP
249.Vb 4
250\& # get's arguments are in the following order:
251\& # ftp server's filename
252\& # filename to save the transfer to on the local machine
253\& # can be simply used as get($name) if you want the same name
254.Ve
255.PP
256.Vb 2
257\& $ftp->get($name,$name);
258\& }
259.Ve
260.PP
261.Vb 1
262\& # ftp done!
263.Ve
264.PP
265.Vb 1
266\& $ftp->quit;
267.Ve
268.Sh "How do I transfer files in binary mode ?"
269.IX Subsection "How do I transfer files in binary mode ?"
270To transfer files without <\s-1LF\s0><\s-1CR\s0> translation Net::FTP provides
271the \f(CW\*(C`binary\*(C'\fR method
272.PP
273.Vb 1
274\& $ftp->binary;
275.Ve
276.Sh "How can I get the size of a file on a remote \s-1FTP\s0 server ?"
277.IX Subsection "How can I get the size of a file on a remote FTP server ?"
278.Sh "How can I get the modification time of a file on a remote \s-1FTP\s0 server ?"
279.IX Subsection "How can I get the modification time of a file on a remote FTP server ?"
280.Sh "How can I change the permissions of a file on a remote server ?"
281.IX Subsection "How can I change the permissions of a file on a remote server ?"
282The \s-1FTP\s0 protocol does not have a command for changing the permissions
283of a file on the remote server. But some ftp servers may allow a chmod
284command to be issued via a \s-1SITE\s0 command, eg
285.PP
286.Vb 1
287\& $ftp->quot('site chmod 0777',$filename);
288.Ve
289.PP
290But this is not guaranteed to work.
291.Sh "Can I do a reget operation like the ftp command ?"
292.IX Subsection "Can I do a reget operation like the ftp command ?"
293.Sh "How do I get a directory listing from an \s-1FTP\s0 server ?"
294.IX Subsection "How do I get a directory listing from an FTP server ?"
295.ie n .Sh "Changing directory to """" does not fail ?"
296.el .Sh "Changing directory to ``'' does not fail ?"
297.IX Subsection "Changing directory to """" does not fail ?"
298Passing an argument of "" to \->\fIcwd()\fR has the same affect of calling \->\fIcwd()\fR
299without any arguments. Turn on Debug (\fISee below\fR) and you will see what is
300happening
301.PP
302.Vb 3
303\& $ftp = Net::FTP->new($host, Debug => 1);
304\& $ftp->login;
305\& $ftp->cwd("");
306.Ve
307.PP
308gives
309.PP
310.Vb 2
311\& Net::FTP=GLOB(0x82196d8)>>> CWD /
312\& Net::FTP=GLOB(0x82196d8)<<< 250 CWD command successful.
313.Ve
314.Sh "I am behind a \s-1SOCKS\s0 firewall, but the Firewall option does not work ?"
315.IX Subsection "I am behind a SOCKS firewall, but the Firewall option does not work ?"
316The Firewall option is only for support of one type of firewall. The type
317supported is an ftp proxy.
318.PP
319To use Net::FTP, or any other module in the libnet distribution,
320through a \s-1SOCKS\s0 firewall you must create a socks-ified perl executable
321by compiling perl with the socks library.
322.Sh "I am behind an \s-1FTP\s0 proxy firewall, but cannot access machines outside ?"
323.IX Subsection "I am behind an FTP proxy firewall, but cannot access machines outside ?"
324Net::FTP implements the most popular ftp proxy firewall approach. The scheme
325implemented is that where you log in to the firewall with \f(CW\*(C`user@hostname\*(C'\fR
326.PP
327I have heard of one other type of firewall which requires a login to the
328firewall with an account, then a second login with \f(CW\*(C`user@hostname\*(C'\fR. You can
329still use Net::FTP to traverse these firewalls, but a more manual approach
330must be taken, eg
331.PP
332.Vb 3
333\& $ftp = Net::FTP->new($firewall) or die $@;
334\& $ftp->login($firewall_user, $firewall_passwd) or die $ftp->message;
335\& $ftp->login($ext_user . '@' . $ext_host, $ext_passwd) or die $ftp->message.
336.Ve
337.Sh "My ftp proxy firewall does not listen on port 21"
338.IX Subsection "My ftp proxy firewall does not listen on port 21"
339\&\s-1FTP\s0 servers usually listen on the same port number, port 21, as any other
340\&\s-1FTP\s0 server. But there is no reason why this has to be the case.
341.PP
342If you pass a port number to Net::FTP then it assumes this is the port
343number of the final destination. By default Net::FTP will always try
344to connect to the firewall on port 21.
345.PP
346Net::FTP uses IO::Socket to open the connection and IO::Socket allows
347the port number to be specified as part of the hostname. So this problem
348can be resolved by either passing a Firewall option like \f(CW"hostname:1234"\fR
349or by setting the \f(CW\*(C`ftp_firewall\*(C'\fR option in Net::Config to be a string
350in in the same form.
351.Sh "Is it possible to change the file permissions of a file on an \s-1FTP\s0 server ?"
352.IX Subsection "Is it possible to change the file permissions of a file on an FTP server ?"
353The answer to this is \*(L"maybe\*(R". The \s-1FTP\s0 protocol does not specify a command to change
354file permissions on a remote host. However many servers do allow you to run the
355chmod command via the \f(CW\*(C`SITE\*(C'\fR command. This can be done with
356.PP
357.Vb 1
358\& $ftp->site('chmod','0775',$file);
359.Ve
360.Sh "I have seen scripts call a method message, but cannot find it documented ?"
361.IX Subsection "I have seen scripts call a method message, but cannot find it documented ?"
362Net::FTP, like several other packages in libnet, inherits from Net::Cmd, so
363all the methods described in Net::Cmd are also available on Net::FTP
364objects.
365.Sh "Why does Net::FTP not implement mput and mget methods"
366.IX Subsection "Why does Net::FTP not implement mput and mget methods"
367The quick answer is because they are easy to implement yourself. The long
368answer is that to write these in such a way that multiple platforms are
369supported correctly would just require too much code. Below are
370some examples how you can implement these yourself.
371.PP
372sub mput {
373 my($ftp,$pattern) = \f(CW@_\fR;
374 foreach my \f(CW$file\fR (glob($pattern)) {
375 \f(CW$ftp\fR\->put($file) or warn \f(CW$ftp\fR\->message;
376 }
377}
378.PP
379sub mget {
380 my($ftp,$pattern) = \f(CW@_\fR;
381 foreach my \f(CW$file\fR ($ftp\->ls($pattern)) {
382 \f(CW$ftp\fR\->get($file) or warn \f(CW$ftp\fR\->message;
383 }
384}
385.SH "Using Net::SMTP"
386.IX Header "Using Net::SMTP"
387.Sh "Why can't the part of an Email address after the @ be used as the hostname ?"
388.IX Subsection "Why can't the part of an Email address after the @ be used as the hostname ?"
389The part of an Email address which follows the @ is not necessarily a hostname,
390it is a mail domain. To find the name of a host to connect for a mail domain
391you need to do a \s-1DNS\s0 \s-1MX\s0 lookup
392.Sh "Why does Net::SMTP not do \s-1DNS\s0 \s-1MX\s0 lookups ?"
393.IX Subsection "Why does Net::SMTP not do DNS MX lookups ?"
394Net::SMTP implements the \s-1SMTP\s0 protocol. The \s-1DNS\s0 \s-1MX\s0 lookup is not part
395of this protocol.
396.Sh "The verify method always returns true ?"
397.IX Subsection "The verify method always returns true ?"
398Well it may seem that way, but it does not. The verify method returns true
399if the command succeeded. If you pass verify an address which the
400server would normally have to forward to another machine, the command
401will succeed with something like
402.PP
403.Vb 1
404\& 252 Couldn't verify <someone@there> but will attempt delivery anyway
405.Ve
406.PP
407This command will fail only if you pass it an address in a domain
408the server directly delivers for, and that address does not exist.
409.SH "Debugging scripts"
410.IX Header "Debugging scripts"
411.Sh "How can I debug my scripts that use Net::* modules ?"
412.IX Subsection "How can I debug my scripts that use Net::* modules ?"
413Most of the libnet client classes allow options to be passed to the
414constructor, in most cases one option is called \f(CW\*(C`Debug\*(C'\fR. Passing
415this option with a non-zero value will turn on a protocol trace, which
416will be sent to \s-1STDERR\s0. This trace can be useful to see what commands
417are being sent to the remote server and what responses are being
418received back.
419.PP
420.Vb 1
421\& #!/your/path/to/perl
422.Ve
423.PP
424.Vb 1
425\& use Net::FTP;
426.Ve
427.PP
428.Vb 3
429\& my $ftp = new Net::FTP($host, Debug => 1);
430\& $ftp->login('gbarr','password');
431\& $ftp->quit;
432.Ve
433.PP
434this script would output something like
435.PP
436.Vb 6
437\& Net::FTP: Net::FTP(2.22)
438\& Net::FTP: Exporter
439\& Net::FTP: Net::Cmd(2.0801)
440\& Net::FTP: IO::Socket::INET
441\& Net::FTP: IO::Socket(1.1603)
442\& Net::FTP: IO::Handle(1.1504)
443.Ve
444.PP
445.Vb 7
446\& Net::FTP=GLOB(0x8152974)<<< 220 imagine FTP server (Version wu-2.4(5) Tue Jul 29 11:17:18 CDT 1997) ready.
447\& Net::FTP=GLOB(0x8152974)>>> user gbarr
448\& Net::FTP=GLOB(0x8152974)<<< 331 Password required for gbarr.
449\& Net::FTP=GLOB(0x8152974)>>> PASS ....
450\& Net::FTP=GLOB(0x8152974)<<< 230 User gbarr logged in. Access restrictions apply.
451\& Net::FTP=GLOB(0x8152974)>>> QUIT
452\& Net::FTP=GLOB(0x8152974)<<< 221 Goodbye.
453.Ve
454.PP
455The first few lines tell you the modules that Net::FTP uses and their versions,
456this is useful data to me when a user reports a bug. The last seven lines
457show the communication with the server. Each line has three parts. The first
458part is the object itself, this is useful for separating the output
459if you are using multiple objects. The second part is either \f(CW\*(C`<<<<\*(C'\fR to
460show data coming from the server or \f(CW\*(C`&gt&gt&gt&gt\*(C'\fR to show data
461going to the server. The remainder of the line is the command
462being sent or response being received.
463.SH "AUTHOR AND COPYRIGHT"
464.IX Header "AUTHOR AND COPYRIGHT"
465Copyright (c) 1997 Graham Barr.
466All rights reserved.
467.PP
468\&\fI$Id: //depot/libnet/Net/libnetFAQ.pod#6 $\fR