libnetfaq.html

来自「perl教程」· HTML 代码 · 共 420 行 · 第 1/2 页

HTML
420
字号
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>libnetFAQ - libnet Frequently Asked Questions</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>

<script>writelinks('__top__',2);</script>
<h1><a>libnetFAQ - libnet Frequently Asked Questions</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<ul>

		<li><a href="#where_to_get_this_document">Where to get this document</a></li>
		<li><a href="#how_to_contribute_to_this_document">How to contribute to this document</a></li>
	</ul>

	<li><a href="#author_and_copyright_information">Author and Copyright Information</a></li>
	<ul>

		<li><a href="#disclaimer">Disclaimer</a></li>
	</ul>

	<li><a href="#obtaining_and_installing_libnet">Obtaining and installing libnet</a></li>
	<ul>

		<li><a href="#what_is_libnet_">What is libnet ?</a></li>
		<li><a href="#which_version_of_perl_do_i_need_">Which version of perl do I need ?</a></li>
		<li><a href="#what_other_modules_do_i_need_">What other modules do I need ?</a></li>
		<li><a href="#what_machines_support_libnet_">What machines support libnet ?</a></li>
		<li><a href="#where_can_i_get_the_latest_libnet_release">Where can I get the latest libnet release</a></li>
	</ul>

	<li><a href="#using_net__ftp">Using Net::FTP</a></li>
	<ul>

		<li><a href="#how_do_i_download_files_from_an_ftp_server_">How do I download files from an FTP server ?</a></li>
		<li><a href="#how_do_i_transfer_files_in_binary_mode_">How do I transfer files in binary mode ?</a></li>
		<li><a href="#how_can_i_get_the_size_of_a_file_on_a_remote_ftp_server_">How can I get the size of a file on a remote FTP server ?</a></li>
		<li><a href="#how_can_i_get_the_modification_time_of_a_file_on_a_remote_ftp_server_">How can I get the modification time of a file on a remote FTP server ?</a></li>
		<li><a href="#how_can_i_change_the_permissions_of_a_file_on_a_remote_server_">How can I change the permissions of a file on a remote server ?</a></li>
		<li><a href="#can_i_do_a_reget_operation_like_the_ftp_command_">Can I do a reget operation like the ftp command ?</a></li>
		<li><a href="#how_do_i_get_a_directory_listing_from_an_ftp_server_">How do I get a directory listing from an FTP server ?</a></li>
		<li><a href="#changing_directory_to__does_not_fail_">Changing directory to &quot;&quot; does not fail ?</a></li>
		<li><a href="#i_am_behind_a_socks_firewall__but_the_firewall_option_does_not_work_">I am behind a SOCKS firewall, but the Firewall option does not work ?</a></li>
		<li><a href="#i_am_behind_an_ftp_proxy_firewall__but_cannot_access_machines_outside_">I am behind an FTP proxy firewall, but cannot access machines outside ?</a></li>
		<li><a href="#my_ftp_proxy_firewall_does_not_listen_on_port_21">My ftp proxy firewall does not listen on port 21</a></li>
		<li><a href="#is_it_possible_to_change_the_file_permissions_of_a_file_on_an_ftp_server_">Is it possible to change the file permissions of a file on an FTP server ?</a></li>
		<li><a href="#i_have_seen_scripts_call_a_method_message__but_cannot_find_it_documented_">I have seen scripts call a method message, but cannot find it documented ?</a></li>
		<li><a href="#why_does_net__ftp_not_implement_mput_and_mget_methods">Why does Net::FTP not implement mput and mget methods</a></li>
	</ul>

	<li><a href="#using_net__smtp">Using Net::SMTP</a></li>
	<ul>

		<li><a href="#why_can_t_the_part_of_an_email_address_after_the___be_used_as_the_hostname_">Why can't the part of an Email address after the @ be used as the hostname ?</a></li>
		<li><a href="#why_does_net__smtp_not_do_dns_mx_lookups_">Why does Net::SMTP not do DNS MX lookups ?</a></li>
		<li><a href="#the_verify_method_always_returns_true_">The verify method always returns true ?</a></li>
	</ul>

	<li><a href="#debugging_scripts">Debugging scripts</a></li>
	<ul>

		<li><a href="#how_can_i_debug_my_scripts_that_use_net____modules_">How can I debug my scripts that use Net::* modules ?</a></li>
	</ul>

	<li><a href="#author_and_copyright">AUTHOR AND COPYRIGHT</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>libnetFAQ - libnet Frequently Asked Questions</p>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>
</p>
<h2><a name="where_to_get_this_document">Where to get this document</a></h2>
<p>This document is distributed with the libnet distribution, and is also
available on the libnet web page at</p>
<pre>
    <a href="http://search.cpan.org/~gbarr/libnet/">http://search.cpan.org/~gbarr/libnet/</a></pre>
<p>
</p>
<h2><a name="how_to_contribute_to_this_document">How to contribute to this document</a></h2>
<p>You may mail corrections, additions, and suggestions to me
<a href="mailto:gbarr@pobox.com.">gbarr@pobox.com.</a></p>
<p>
</p>
<hr />
<h1><a name="author_and_copyright_information">Author and Copyright Information</a></h1>
<p>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.</p>
<p>
</p>
<h2><a name="disclaimer">Disclaimer</a></h2>
<p>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.</p>
<p>
</p>
<hr />
<h1><a name="obtaining_and_installing_libnet">Obtaining and installing libnet</a></h1>
<p>
</p>
<h2><a name="what_is_libnet_">What is libnet ?</a></h2>
<p>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.</p>
<p>
</p>
<h2><a name="which_version_of_perl_do_i_need_">Which version of perl do I need ?</a></h2>
<p>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 IO distribution from CPAN. If you have perl5.004
or later then you will have the IO modules in your installation already,
but CPAN may contain updates.</p>
<p>
</p>
<h2><a name="what_other_modules_do_i_need_">What other modules do I need ?</a></h2>
<p>The only modules you will need installed are the modules from the IO
distribution. If you have perl5.004 or later you will already have
these modules.</p>
<p>
</p>
<h2><a name="what_machines_support_libnet_">What machines support libnet ?</a></h2>
<p>libnet itself is an entirely perl-code distribution so it should work
on any machine that perl runs on. However IO 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.</p>
<p>
</p>
<h2><a name="where_can_i_get_the_latest_libnet_release">Where can I get the latest libnet release</a></h2>
<p>The latest libnet release is always on CPAN, you will find it
in</p>
<pre>
 <a href="http://www.cpan.org/modules/by-module/Net/">http://www.cpan.org/modules/by-module/Net/</a></pre>
<p>The latest release and information is also available on the libnet web page
at</p>
<pre>
 <a href="http://search.cpan.org/~gbarr/libnet/">http://search.cpan.org/~gbarr/libnet/</a></pre>
<p>
</p>
<hr />
<h1><a name="using_net__ftp">Using Net::FTP</a></h1>
<p>
</p>
<h2><a name="how_do_i_download_files_from_an_ftp_server_">How do I download files from an FTP server ?</a></h2>
<p>An example taken from an article posted to comp.lang.perl.misc</p>
<pre>
    <span class="comment">#!/your/path/to/perl</span>
</pre>
<pre>
    <span class="comment"># a module making life easier</span>
</pre>
<pre>
    <span class="keyword">use</span> <span class="variable">Net::FTP</span><span class="operator">;</span>
</pre>
<pre>
    <span class="comment"># for debuging: $ftp = Net::FTP-&gt;new('site','Debug',10);</span>
    <span class="comment"># open a connection and log in!</span>
</pre>
<pre>
    <span class="variable">$ftp</span> <span class="operator">=</span> <span class="variable">Net::FTP</span><span class="operator">-&gt;</span><span class="variable">new</span><span class="operator">(</span><span class="string">'target_site.somewhere.xxx'</span><span class="operator">);</span>
    <span class="variable">$ftp</span><span class="operator">-&gt;</span><span class="variable">login</span><span class="operator">(</span><span class="string">'username'</span><span class="operator">,</span><span class="string">'password'</span><span class="operator">);</span>
</pre>
<pre>
    <span class="comment"># set transfer mode to binary</span>
</pre>
<pre>
    <span class="variable">$ftp</span><span class="operator">-&gt;</span><span class="variable">binary</span><span class="operator">();</span>
</pre>
<pre>
    <span class="comment"># change the directory on the ftp site</span>
</pre>
<pre>
    <span class="variable">$ftp</span><span class="operator">-&gt;</span><span class="variable">cwd</span><span class="operator">(</span><span class="string">'/some/path/to/somewhere/'</span><span class="operator">);</span>
</pre>
<pre>
    <span class="keyword">foreach</span> <span class="variable">$name</span> <span class="operator">(</span><span class="string">'file1'</span><span class="operator">,</span> <span class="string">'file2'</span><span class="operator">,</span> <span class="string">'file3'</span><span class="operator">)</span> <span class="operator">{</span>
</pre>
<pre>
    <span class="comment"># get's arguments are in the following order:</span>
    <span class="comment"># ftp server's filename</span>
    <span class="comment"># filename to save the transfer to on the local machine</span>
    <span class="comment"># can be simply used as get($name) if you want the same name</span>
</pre>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?