1Net::Cmd(3pm)          Perl Programmers Reference Guide          Net::Cmd(3pm)
2
3
4

NAME

6       Net::Cmd - Network Command class (as used by FTP, SMTP etc)
7

SYNOPSIS

9           use Net::Cmd;
10
11           @ISA = qw(Net::Cmd);
12

DESCRIPTION

14       "Net::Cmd" is a collection of methods that can be inherited by a sub
15       class of "IO::Handle". These methods implement the functionality
16       required for a command based protocol, for example FTP and SMTP.
17

USER METHODS

19       These methods provide a user interface to the "Net::Cmd" object.
20
21       debug ( VALUE )
22           Set the level of debug information for this object. If "VALUE" is
23           not given then the current state is returned. Otherwise the state
24           is changed to "VALUE" and the previous state returned.
25
26           Different packages may implement different levels of debug but a
27           non-zero value results in copies of all commands and responses also
28           being sent to STDERR.
29
30           If "VALUE" is "undef" then the debug level will be set to the
31           default debug level for the class.
32
33           This method can also be called as a static method to set/get the
34           default debug level for a given class.
35
36       message ()
37           Returns the text message returned from the last command
38
39       code ()
40           Returns the 3-digit code from the last command. If a command is
41           pending then the value 0 is returned
42
43       ok ()
44           Returns non-zero if the last code value was greater than zero and
45           less than 400. This holds true for most command servers. Servers
46           where this does not hold may override this method.
47
48       status ()
49           Returns the most significant digit of the current status code. If a
50           command is pending then "CMD_PENDING" is returned.
51
52       datasend ( DATA )
53           Send data to the remote server, converting LF to CRLF. Any line
54           starting with a '.' will be prefixed with another '.'.  "DATA" may
55           be an array or a reference to an array.
56
57       dataend ()
58           End the sending of data to the remote server. This is done by
59           ensuring that the data already sent ends with CRLF then sending
60           '.CRLF' to end the transmission. Once this data has been sent
61           "dataend" calls "response" and returns true if "response" returns
62           CMD_OK.
63

CLASS METHODS

65       These methods are not intended to be called by the user, but used or
66       over-ridden by a sub-class of "Net::Cmd"
67
68       debug_print ( DIR, TEXT )
69           Print debugging information. "DIR" denotes the direction true being
70           data being sent to the server. Calls "debug_text" before printing
71           to STDERR.
72
73       debug_text ( TEXT )
74           This method is called to print debugging information. TEXT is the
75           text being sent. The method should return the text to be printed
76
77           This is primarily meant for the use of modules such as FTP where
78           passwords are sent, but we do not want to display them in the
79           debugging information.
80
81       command ( CMD [, ARGS, ... ])
82           Send a command to the command server. All arguments a first joined
83           with a space character and CRLF is appended, this string is then
84           sent to the command server.
85
86           Returns undef upon failure
87
88       unsupported ()
89           Sets the status code to 580 and the response text to 'Unsupported
90           command'.  Returns zero.
91
92       response ()
93           Obtain a response from the server. Upon success the most
94           significant digit of the status code is returned. Upon failure,
95           timeout etc., undef is returned.
96
97       parse_response ( TEXT )
98           This method is called by "response" as a method with one argument.
99           It should return an array of 2 values, the 3-digit status code and
100           a flag which is true when this is part of a multi-line response and
101           this line is not the list.
102
103       getline ()
104           Retrieve one line, delimited by CRLF, from the remote server.
105           Returns undef upon failure.
106
107           NOTE: If you do use this method for any reason, please remember to
108           add some "debug_print" calls into your method.
109
110       ungetline ( TEXT )
111           Unget a line of text from the server.
112
113       rawdatasend ( DATA )
114           Send data to the remote server without performing any conversions.
115           "DATA" is a scalar.
116
117       read_until_dot ()
118           Read data from the remote server until a line consisting of a
119           single '.'.  Any lines starting with '..' will have one of the '.'s
120           removed.
121
122           Returns a reference to a list containing the lines, or undef upon
123           failure.
124
125       tied_fh ()
126           Returns a filehandle tied to the Net::Cmd object.  After issuing a
127           command, you may read from this filehandle using read() or <>.  The
128           filehandle will return EOF when the final dot is encountered.
129           Similarly, you may write to the filehandle in order to send data to
130           the server after issuing a command that expects data to be written.
131
132           See the Net::POP3 and Net::SMTP modules for examples of this.
133

EXPORTS

135       "Net::Cmd" exports six subroutines, five of these, "CMD_INFO",
136       "CMD_OK", "CMD_MORE", "CMD_REJECT" and "CMD_ERROR", correspond to
137       possible results of "response" and "status". The sixth is
138       "CMD_PENDING".
139

AUTHOR

141       Graham Barr <gbarr@pobox.com>
142
144       Copyright (c) 1995-2006 Graham Barr. All rights reserved.  This program
145       is free software; you can redistribute it and/or modify it under the
146       same terms as Perl itself.
147
148
149
150perl v5.10.1                      2009-02-12                     Net::Cmd(3pm)
Impressum