⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 net::libnetfaq.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 2 页
字号:
\&    # open a connection and log in!\&\&    $ftp = Net::FTP\->new(\*(Aqtarget_site.somewhere.xxx\*(Aq);\&    $ftp\->login(\*(Aqusername\*(Aq,\*(Aqpassword\*(Aq);\&\&    # set transfer mode to binary\&\&    $ftp\->binary();\&\&    # change the directory on the ftp site\&\&    $ftp\->cwd(\*(Aq/some/path/to/somewhere/\*(Aq);\&\&    foreach $name (\*(Aqfile1\*(Aq, \*(Aqfile2\*(Aq, \*(Aqfile3\*(Aq) {\&\&    # get\*(Aqs arguments are in the following order:\&    # ftp server\*(Aqs filename\&    # filename to save the transfer to on the local machine\&    # can be simply used as get($name) if you want the same name\&\&      $ftp\->get($name,$name);\&    }\&\&    # ftp done!\&\&    $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 providesthe \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 permissionsof a file on the remote server. But some ftp servers may allow a chmodcommand to be issued via a \s-1SITE\s0 command, eg.PP.Vb 1\&    $ftp\->quot(\*(Aqsite chmod 0777\*(Aq,$filename);.Ve.PPBut 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()\fRwithout any arguments. Turn on Debug (\fISee below\fR) and you will see what ishappening.PP.Vb 3\&    $ftp = Net::FTP\->new($host, Debug => 1);\&    $ftp\->login;\&    $ftp\->cwd("");.Ve.PPgives.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 typesupported is an ftp proxy..PPTo use Net::FTP, or any other module in the libnet distribution,through a \s-1SOCKS\s0 firewall you must create a socks-ified perl executableby 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 schemeimplemented is that where you log in to the firewall with \f(CW\*(C`user@hostname\*(C'\fR.PPI have heard of one other type of firewall which requires a login to thefirewall with an account, then a second login with \f(CW\*(C`user@hostname\*(C'\fR. You canstill use Net::FTP to traverse these firewalls, but a more manual approachmust 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 . \*(Aq@\*(Aq . $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..PPIf you pass a port number to Net::FTP then it assumes this is the portnumber of the final destination. By default Net::FTP will always tryto connect to the firewall on port 21..PPNet::FTP uses IO::Socket to open the connection and IO::Socket allowsthe port number to be specified as part of the hostname. So this problemcan be resolved by either passing a Firewall option like \f(CW"hostname:1234"\fRor by setting the \f(CW\*(C`ftp_firewall\*(C'\fR option in Net::Config to be a stringin 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 changefile permissions on a remote host. However many servers do allow you to run thechmod command via the \f(CW\*(C`SITE\*(C'\fR command. This can be done with.PP.Vb 1\&  $ftp\->site(\*(Aqchmod\*(Aq,\*(Aq0775\*(Aq,$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, soall the methods described in Net::Cmd are also available on Net::FTPobjects..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 longanswer is that to write these in such a way that multiple platforms aresupported correctly would just require too much code. Below aresome examples how you can implement these yourself..PPsub 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;  }}.PPsub 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 domainyou 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 partof 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 trueif the command succeeded. If you pass verify an address which theserver would normally have to forward to another machine, the commandwill succeed with something like.PP.Vb 1\&    252 Couldn\*(Aqt verify <someone@there> but will attempt delivery anyway.Ve.PPThis command will fail only if you pass it an address in a domainthe 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 theconstructor, in most cases one option is called \f(CW\*(C`Debug\*(C'\fR. Passingthis option with a non-zero value will turn on a protocol trace, whichwill be sent to \s-1STDERR\s0. This trace can be useful to see what commandsare being sent to the remote server and what responses are beingreceived back..PP.Vb 1\&    #!/your/path/to/perl\&\&    use Net::FTP;\&\&    my $ftp = new Net::FTP($host, Debug => 1);\&    $ftp\->login(\*(Aqgbarr\*(Aq,\*(Aqpassword\*(Aq);\&    $ftp\->quit;.Ve.PPthis 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)\&\& 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.PPThe 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 linesshow the communication with the server. Each line has three parts. The firstpart is the object itself, this is useful for separating the outputif you are using multiple objects. The second part is either \f(CW\*(C`<<<<\*(C'\fR toshow data coming from the server or \f(CW\*(C`&gt&gt&gt&gt\*(C'\fR to show datagoing to the server. The remainder of the line is the commandbeing sent or response being received..SH "AUTHOR AND COPYRIGHT".IX Header "AUTHOR AND COPYRIGHT"Copyright (c) 1997 Graham Barr.All rights reserved.

⌨️ 快捷键说明

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