📄 net::ftp.3
字号:
Change directory to the parent of the current directory..IP "pwd ()" 4.IX Item "pwd ()"Returns the full pathname of the current directory..IP "restart ( \s-1WHERE\s0 )" 4.IX Item "restart ( WHERE )"Set the byte offset at which to begin the next data transfer. Net::FTP simplyrecords this value and uses it when during the next data transfer. For thisreason this method will not return an error, but setting it may causea subsequent data transfer to fail..IP "rmdir ( \s-1DIR\s0 [, \s-1RECURSE\s0 ])" 4.IX Item "rmdir ( DIR [, RECURSE ])"Remove the directory with the name \f(CW\*(C`DIR\*(C'\fR. If \f(CW\*(C`RECURSE\*(C'\fR is \fItrue\fR then\&\f(CW\*(C`rmdir\*(C'\fR will attempt to delete everything inside the directory..IP "mkdir ( \s-1DIR\s0 [, \s-1RECURSE\s0 ])" 4.IX Item "mkdir ( DIR [, RECURSE ])"Create a new directory with the name \f(CW\*(C`DIR\*(C'\fR. If \f(CW\*(C`RECURSE\*(C'\fR is \fItrue\fR then\&\f(CW\*(C`mkdir\*(C'\fR will attempt to create all the directories in the given path..SpReturns the full pathname to the new directory..IP "alloc ( \s-1SIZE\s0 [, \s-1RECORD_SIZE\s0] )" 4.IX Item "alloc ( SIZE [, RECORD_SIZE] )"The alloc command allows you to give the ftp server a hint about the sizeof the file about to be transferred using the \s-1ALLO\s0 ftp command. Some storagesystems use this to make intelligent decisions about how to store the file.The \f(CW\*(C`SIZE\*(C'\fR argument represents the size of the file in bytes. The\&\f(CW\*(C`RECORD_SIZE\*(C'\fR argument indicates a maximum record or page size for filessent with a record or page structure..SpThe size of the file will be determined, and sent to the serverautomatically for normal files so that this method need only be called ifyou are transferring data from a socket, named pipe, or other stream notassociated with a normal file..IP "ls ( [ \s-1DIR\s0 ] )" 4.IX Item "ls ( [ DIR ] )"Get a directory listing of \f(CW\*(C`DIR\*(C'\fR, or the current directory..SpIn an array context, returns a list of lines returned from the server. Ina scalar context, returns a reference to a list..IP "dir ( [ \s-1DIR\s0 ] )" 4.IX Item "dir ( [ DIR ] )"Get a directory listing of \f(CW\*(C`DIR\*(C'\fR, or the current directory in long format..SpIn an array context, returns a list of lines returned from the server. Ina scalar context, returns a reference to a list..IP "get ( \s-1REMOTE_FILE\s0 [, \s-1LOCAL_FILE\s0 [, \s-1WHERE\s0]] )" 4.IX Item "get ( REMOTE_FILE [, LOCAL_FILE [, WHERE]] )"Get \f(CW\*(C`REMOTE_FILE\*(C'\fR from the server and store locally. \f(CW\*(C`LOCAL_FILE\*(C'\fR may bea filename or a filehandle. If not specified, the file will be stored inthe current directory with the same leafname as the remote file..SpIf \f(CW\*(C`WHERE\*(C'\fR is given then the first \f(CW\*(C`WHERE\*(C'\fR bytes of the file willnot be transferred, and the remaining bytes will be appended tothe local file if it already exists..SpReturns \f(CW\*(C`LOCAL_FILE\*(C'\fR, or the generated local file name if \f(CW\*(C`LOCAL_FILE\*(C'\fRis not given. If an error was encountered undef is returned..IP "put ( \s-1LOCAL_FILE\s0 [, \s-1REMOTE_FILE\s0 ] )" 4.IX Item "put ( LOCAL_FILE [, REMOTE_FILE ] )"Put a file on the remote server. \f(CW\*(C`LOCAL_FILE\*(C'\fR may be a name or a filehandle.If \f(CW\*(C`LOCAL_FILE\*(C'\fR is a filehandle then \f(CW\*(C`REMOTE_FILE\*(C'\fR must be specified. If\&\f(CW\*(C`REMOTE_FILE\*(C'\fR is not specified then the file will be stored in the currentdirectory with the same leafname as \f(CW\*(C`LOCAL_FILE\*(C'\fR..SpReturns \f(CW\*(C`REMOTE_FILE\*(C'\fR, or the generated remote filename if \f(CW\*(C`REMOTE_FILE\*(C'\fRis not given..Sp\&\fB\s-1NOTE\s0\fR: If for some reason the transfer does not complete and an error isreturned then the contents that had been transferred will not be removeautomatically..IP "put_unique ( \s-1LOCAL_FILE\s0 [, \s-1REMOTE_FILE\s0 ] )" 4.IX Item "put_unique ( LOCAL_FILE [, REMOTE_FILE ] )"Same as put but uses the \f(CW\*(C`STOU\*(C'\fR command..SpReturns the name of the file on the server..IP "append ( \s-1LOCAL_FILE\s0 [, \s-1REMOTE_FILE\s0 ] )" 4.IX Item "append ( LOCAL_FILE [, REMOTE_FILE ] )"Same as put but appends to the file on the remote server..SpReturns \f(CW\*(C`REMOTE_FILE\*(C'\fR, or the generated remote filename if \f(CW\*(C`REMOTE_FILE\*(C'\fRis not given..IP "unique_name ()" 4.IX Item "unique_name ()"Returns the name of the last file stored on the server using the\&\f(CW\*(C`STOU\*(C'\fR command..IP "mdtm ( \s-1FILE\s0 )" 4.IX Item "mdtm ( FILE )"Returns the \fImodification time\fR of the given file.IP "size ( \s-1FILE\s0 )" 4.IX Item "size ( FILE )"Returns the size in bytes for the given file as stored on the remote server..Sp\&\fB\s-1NOTE\s0\fR: The size reported is the size of the stored file on the remote server.If the file is subsequently transferred from the server in \s-1ASCII\s0 modeand the remote server and local machine have different ideas about\&\*(L"End Of Line\*(R" then the size of file on the local machine after transfermay be different..IP "supported ( \s-1CMD\s0 )" 4.IX Item "supported ( CMD )"Returns \s-1TRUE\s0 if the remote server supports the given command..IP "hash ( [\s-1FILEHANDLE_GLOB_REF\s0],[ \s-1BYTES_PER_HASH_MARK\s0] )" 4.IX Item "hash ( [FILEHANDLE_GLOB_REF],[ BYTES_PER_HASH_MARK] )"Called without parameters, or with the first argument false, hash marksare suppressed. If the first argument is true but not a reference to a file handle glob, then \e*STDERR is used. The second argument is the numberof bytes per hash mark printed, and defaults to 1024. In all cases thereturn value is a reference to an array of two: the filehandle glob referenceand the bytes per hash mark..IP "feature ( \s-1NAME\s0 )" 4.IX Item "feature ( NAME )"Determine if the server supports the specified feature. The returnvalue is a list of lines the server responded with to describe theoptions that it supports for the given feature. If the feature isunsupported then the empty list is returned..Sp.Vb 3\& if ($ftp\->feature( \*(AqMDTM\*(Aq )) {\& # Do something\& }\&\& if (grep { /\ebTLS\eb/ } $ftp\->feature(\*(AqAUTH\*(Aq)) {\& # Server supports TLS\& }.Ve.PPThe following methods can return different results depending onhow they are called. If the user explicitly calls eitherof the \f(CW\*(C`pasv\*(C'\fR or \f(CW\*(C`port\*(C'\fR methods then these methods willreturn a \fItrue\fR or \fIfalse\fR value. If the user does notcall either of these methods then the result will be areference to a \f(CW\*(C`Net::FTP::dataconn\*(C'\fR based object..IP "nlst ( [ \s-1DIR\s0 ] )" 4.IX Item "nlst ( [ DIR ] )"Send an \f(CW\*(C`NLST\*(C'\fR command to the server, with an optional parameter..IP "list ( [ \s-1DIR\s0 ] )" 4.IX Item "list ( [ DIR ] )"Same as \f(CW\*(C`nlst\*(C'\fR but using the \f(CW\*(C`LIST\*(C'\fR command.IP "retr ( \s-1FILE\s0 )" 4.IX Item "retr ( FILE )"Begin the retrieval of a file called \f(CW\*(C`FILE\*(C'\fR from the remote server..IP "stor ( \s-1FILE\s0 )" 4.IX Item "stor ( FILE )"Tell the server that you wish to store a file. \f(CW\*(C`FILE\*(C'\fR is thename of the new file that should be created..IP "stou ( \s-1FILE\s0 )" 4.IX Item "stou ( FILE )"Same as \f(CW\*(C`stor\*(C'\fR but using the \f(CW\*(C`STOU\*(C'\fR command. The name of the uniquefile which was created on the server will be available via the \f(CW\*(C`unique_name\*(C'\fRmethod after the data connection has been closed..IP "appe ( \s-1FILE\s0 )" 4.IX Item "appe ( FILE )"Tell the server that we want to append some data to the end of a filecalled \f(CW\*(C`FILE\*(C'\fR. If this file does not exist then create it..PPIf for some reason you want to have complete control over the data connection,this includes generating it and calling the \f(CW\*(C`response\*(C'\fR method when required,then the user can use these methods to do so..PPHowever calling these methods only affects the use of the methods above thatcan return a data connection. They have no effect on methods \f(CW\*(C`get\*(C'\fR, \f(CW\*(C`put\*(C'\fR,\&\f(CW\*(C`put_unique\*(C'\fR and those that do not require data connections..IP "port ( [ \s-1PORT\s0 ] )" 4.IX Item "port ( [ PORT ] )"Send a \f(CW\*(C`PORT\*(C'\fR command to the server. If \f(CW\*(C`PORT\*(C'\fR is specified then it is sentto the server. If not, then a listen socket is created and the correct informationsent to the server..IP "pasv ()" 4.IX Item "pasv ()"Tell the server to go into passive mode. Returns the text that represents theport on which the server is listening, this text is in a suitable form tosent to another ftp server using the \f(CW\*(C`port\*(C'\fR method..PPThe following methods can be used to transfer files between two remoteservers, providing that these two servers can connect directly to each other..IP "pasv_xfer ( \s-1SRC_FILE\s0, \s-1DEST_SERVER\s0 [, \s-1DEST_FILE\s0 ] )" 4.IX Item "pasv_xfer ( SRC_FILE, DEST_SERVER [, DEST_FILE ] )"This method will do a file transfer between two remote ftp servers. If\&\f(CW\*(C`DEST_FILE\*(C'\fR is omitted then the leaf name of \f(CW\*(C`SRC_FILE\*(C'\fR will be used..IP "pasv_xfer_unique ( \s-1SRC_FILE\s0, \s-1DEST_SERVER\s0 [, \s-1DEST_FILE\s0 ] )" 4.IX Item "pasv_xfer_unique ( SRC_FILE, DEST_SERVER [, DEST_FILE ] )"Like \f(CW\*(C`pasv_xfer\*(C'\fR but the file is stored on the remote server usingthe \s-1STOU\s0 command..IP "pasv_wait ( \s-1NON_PASV_SERVER\s0 )" 4.IX Item "pasv_wait ( NON_PASV_SERVER )"This method can be used to wait for a transfer to complete between a passiveserver and a non-passive server. The method should be called on the passiveserver with the \f(CW\*(C`Net::FTP\*(C'\fR object for the non-passive server passed as anargument..IP "abort ()" 4.IX Item "abort ()"Abort the current data transfer..IP "quit ()" 4.IX Item "quit ()"Send the \s-1QUIT\s0 command to the remote \s-1FTP\s0 server and close the socket connection..Sh "Methods for the adventurous".IX Subsection "Methods for the adventurous"\&\f(CW\*(C`Net::FTP\*(C'\fR inherits from \f(CW\*(C`Net::Cmd\*(C'\fR so methods defined in \f(CW\*(C`Net::Cmd\*(C'\fR maybe used to send commands to the remote \s-1FTP\s0 server..IP "quot (\s-1CMD\s0 [,ARGS])" 4.IX Item "quot (CMD [,ARGS])"Send a command, that Net::FTP does not directly support, to the remoteserver and wait for a response..SpReturns most significant digit of the response code..Sp\&\fB\s-1WARNING\s0\fR This call should only be used on commands that do not requiredata connections. Misuse of this method can hang the connection..SH "THE dataconn CLASS".IX Header "THE dataconn CLASS"Some of the methods defined in \f(CW\*(C`Net::FTP\*(C'\fR return an object which willbe derived from this class.The dataconn class itself is derived fromthe \f(CW\*(C`IO::Socket::INET\*(C'\fR class, so any normal \s-1IO\s0 operations can be performed.However the following methods are defined in the dataconn class and \s-1IO\s0 shouldbe performed using these..IP "read ( \s-1BUFFER\s0, \s-1SIZE\s0 [, \s-1TIMEOUT\s0 ] )" 4.IX Item "read ( BUFFER, SIZE [, TIMEOUT ] )"Read \f(CW\*(C`SIZE\*(C'\fR bytes of data from the server and place it into \f(CW\*(C`BUFFER\*(C'\fR, alsoperforming any <\s-1CRLF\s0> translation necessary. \f(CW\*(C`TIMEOUT\*(C'\fR is optional, if notgiven, the timeout value from the command connection will be used..SpReturns the number of bytes read before any <\s-1CRLF\s0> translation..IP "write ( \s-1BUFFER\s0, \s-1SIZE\s0 [, \s-1TIMEOUT\s0 ] )" 4.IX Item "write ( BUFFER, SIZE [, TIMEOUT ] )"Write \f(CW\*(C`SIZE\*(C'\fR bytes of data from \f(CW\*(C`BUFFER\*(C'\fR to the server, alsoperforming any <\s-1CRLF\s0> translation necessary. \f(CW\*(C`TIMEOUT\*(C'\fR is optional, if notgiven, the timeout value from the command connection will be used..SpReturns the number of bytes written before any <\s-1CRLF\s0> translation..IP "bytes_read ()" 4.IX Item "bytes_read ()"Returns the number of bytes read so far..IP "abort ()" 4.IX Item "abort ()"Abort the current data transfer..IP "close ()" 4.IX Item "close ()"Close the data connection and get a response from the \s-1FTP\s0 server. Returns\&\fItrue\fR if the connection was closed successfully and the first digit ofthe response from the server was a '2'..SH "UNIMPLEMENTED".IX Header "UNIMPLEMENTED"The following \s-1RFC959\s0 commands have not been implemented:.IP "\fB\s-1SMNT\s0\fR" 4.IX Item "SMNT"Mount a different file system structure without changing login oraccounting information..IP "\fB\s-1HELP\s0\fR" 4.IX Item "HELP"Ask the server for \*(L"helpful information\*(R" (that's what the \s-1RFC\s0 says) onthe commands it accepts..IP "\fB\s-1MODE\s0\fR" 4.IX Item "MODE"Specifies transfer mode (stream, block or compressed) for file to betransferred..IP "\fB\s-1SYST\s0\fR" 4.IX Item "SYST"Request remote server system identification..IP "\fB\s-1STAT\s0\fR" 4.IX Item "STAT"Request remote server status..IP "\fB\s-1STRU\s0\fR" 4.IX Item "STRU"Specifies file structure for file to be transferred..IP "\fB\s-1REIN\s0\fR" 4.IX Item "REIN"Reinitialize the connection, flushing all I/O and account information..SH "REPORTING BUGS".IX Header "REPORTING BUGS"When reporting bugs/problems please include as much information as possible.It may be difficult for me to reproduce the problem as almost every setupis different..PPA small script which yields the problem will probably be of help. It wouldalso be useful if this script was run with the extra options \f(CW\*(C`Debug =\*(C'\fR 1>passed to the constructor, and the output sent with the bug report. If youcannot include a small script then please include a Debug trace from arun of your program which does yield the problem..SH "AUTHOR".IX Header "AUTHOR"Graham Barr <gbarr@pobox.com>.SH "SEE ALSO".IX Header "SEE ALSO"Net::NetrcNet::Cmd.PP\&\fIftp\fR\|(1), \fIftpd\fR\|(8), \s-1RFC\s0 959http://www.cis.ohio\-state.edu/htbin/rfc/rfc959.html.SH "USE EXAMPLES".IX Header "USE EXAMPLES"For an example of the use of Net::FTP see.IP "http://www.csh.rit.edu/~adam/Progs/" 4.IX Item "http://www.csh.rit.edu/~adam/Progs/"\&\f(CW\*(C`autoftp\*(C'\fR is a program that can retrieve, send, or list files viathe \s-1FTP\s0 protocol in a non-interactive manner..SH "CREDITS".IX Header "CREDITS"Henry Gabryjelski <henryg@WPI.EDU> \- for the suggestion of creating directoriesrecursively..PPNathan Torkington <gnat@frii.com> \- for some input on the documentation..PPRoderick Schertler <roderick@gate.net> \- for various inputs.SH "COPYRIGHT".IX Header "COPYRIGHT"Copyright (c) 1995\-2004 Graham Barr. All rights reserved.This program is free software; you can redistribute it and/or modify itunder the same terms as Perl itself.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -