| 1 | .\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 |
| 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::Cmd 3" |
| 132 | .TH Net::Cmd 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide" |
| 133 | .SH "NAME" |
| 134 | Net::Cmd \- Network Command class (as used by FTP, SMTP etc) |
| 135 | .SH "SYNOPSIS" |
| 136 | .IX Header "SYNOPSIS" |
| 137 | .Vb 1 |
| 138 | \& use Net::Cmd; |
| 139 | .Ve |
| 140 | .PP |
| 141 | .Vb 1 |
| 142 | \& @ISA = qw(Net::Cmd); |
| 143 | .Ve |
| 144 | .SH "DESCRIPTION" |
| 145 | .IX Header "DESCRIPTION" |
| 146 | \&\f(CW\*(C`Net::Cmd\*(C'\fR is a collection of methods that can be inherited by a sub class |
| 147 | of \f(CW\*(C`IO::Handle\*(C'\fR. These methods implement the functionality required for a |
| 148 | command based protocol, for example \s-1FTP\s0 and \s-1SMTP\s0. |
| 149 | .SH "USER METHODS" |
| 150 | .IX Header "USER METHODS" |
| 151 | These methods provide a user interface to the \f(CW\*(C`Net::Cmd\*(C'\fR object. |
| 152 | .IP "debug ( \s-1VALUE\s0 )" 4 |
| 153 | .IX Item "debug ( VALUE )" |
| 154 | Set the level of debug information for this object. If \f(CW\*(C`VALUE\*(C'\fR is not given |
| 155 | then the current state is returned. Otherwise the state is changed to |
| 156 | \&\f(CW\*(C`VALUE\*(C'\fR and the previous state returned. |
| 157 | .Sp |
| 158 | Different packages |
| 159 | may implement different levels of debug but a non-zero value results in |
| 160 | copies of all commands and responses also being sent to \s-1STDERR\s0. |
| 161 | .Sp |
| 162 | If \f(CW\*(C`VALUE\*(C'\fR is \f(CW\*(C`undef\*(C'\fR then the debug level will be set to the default |
| 163 | debug level for the class. |
| 164 | .Sp |
| 165 | This method can also be called as a \fIstatic\fR method to set/get the default |
| 166 | debug level for a given class. |
| 167 | .IP "message ()" 4 |
| 168 | .IX Item "message ()" |
| 169 | Returns the text message returned from the last command |
| 170 | .IP "code ()" 4 |
| 171 | .IX Item "code ()" |
| 172 | Returns the 3\-digit code from the last command. If a command is pending |
| 173 | then the value 0 is returned |
| 174 | .IP "ok ()" 4 |
| 175 | .IX Item "ok ()" |
| 176 | Returns non-zero if the last code value was greater than zero and |
| 177 | less than 400. This holds true for most command servers. Servers |
| 178 | where this does not hold may override this method. |
| 179 | .IP "status ()" 4 |
| 180 | .IX Item "status ()" |
| 181 | Returns the most significant digit of the current status code. If a command |
| 182 | is pending then \f(CW\*(C`CMD_PENDING\*(C'\fR is returned. |
| 183 | .IP "datasend ( \s-1DATA\s0 )" 4 |
| 184 | .IX Item "datasend ( DATA )" |
| 185 | Send data to the remote server, converting \s-1LF\s0 to \s-1CRLF\s0. Any line starting |
| 186 | with a '.' will be prefixed with another '.'. |
| 187 | \&\f(CW\*(C`DATA\*(C'\fR may be an array or a reference to an array. |
| 188 | .IP "dataend ()" 4 |
| 189 | .IX Item "dataend ()" |
| 190 | End the sending of data to the remote server. This is done by ensuring that |
| 191 | the data already sent ends with \s-1CRLF\s0 then sending '.CRLF' to end the |
| 192 | transmission. Once this data has been sent \f(CW\*(C`dataend\*(C'\fR calls \f(CW\*(C`response\*(C'\fR and |
| 193 | returns true if \f(CW\*(C`response\*(C'\fR returns \s-1CMD_OK\s0. |
| 194 | .SH "CLASS METHODS" |
| 195 | .IX Header "CLASS METHODS" |
| 196 | These methods are not intended to be called by the user, but used or |
| 197 | over-ridden by a sub-class of \f(CW\*(C`Net::Cmd\*(C'\fR |
| 198 | .IP "debug_print ( \s-1DIR\s0, \s-1TEXT\s0 )" 4 |
| 199 | .IX Item "debug_print ( DIR, TEXT )" |
| 200 | Print debugging information. \f(CW\*(C`DIR\*(C'\fR denotes the direction \fItrue\fR being |
| 201 | data being sent to the server. Calls \f(CW\*(C`debug_text\*(C'\fR before printing to |
| 202 | \&\s-1STDERR\s0. |
| 203 | .IP "debug_text ( \s-1TEXT\s0 )" 4 |
| 204 | .IX Item "debug_text ( TEXT )" |
| 205 | This method is called to print debugging information. \s-1TEXT\s0 is |
| 206 | the text being sent. The method should return the text to be printed |
| 207 | .Sp |
| 208 | This is primarily meant for the use of modules such as \s-1FTP\s0 where passwords |
| 209 | are sent, but we do not want to display them in the debugging information. |
| 210 | .IP "command ( \s-1CMD\s0 [, \s-1ARGS\s0, ... ])" 4 |
| 211 | .IX Item "command ( CMD [, ARGS, ... ])" |
| 212 | Send a command to the command server. All arguments a first joined with |
| 213 | a space character and \s-1CRLF\s0 is appended, this string is then sent to the |
| 214 | command server. |
| 215 | .Sp |
| 216 | Returns undef upon failure |
| 217 | .IP "unsupported ()" 4 |
| 218 | .IX Item "unsupported ()" |
| 219 | Sets the status code to 580 and the response text to 'Unsupported command'. |
| 220 | Returns zero. |
| 221 | .IP "response ()" 4 |
| 222 | .IX Item "response ()" |
| 223 | Obtain a response from the server. Upon success the most significant digit |
| 224 | of the status code is returned. Upon failure, timeout etc., \fIundef\fR is |
| 225 | returned. |
| 226 | .IP "parse_response ( \s-1TEXT\s0 )" 4 |
| 227 | .IX Item "parse_response ( TEXT )" |
| 228 | This method is called by \f(CW\*(C`response\*(C'\fR as a method with one argument. It should |
| 229 | return an array of 2 values, the 3\-digit status code and a flag which is true |
| 230 | when this is part of a multi-line response and this line is not the list. |
| 231 | .IP "getline ()" 4 |
| 232 | .IX Item "getline ()" |
| 233 | Retrieve one line, delimited by \s-1CRLF\s0, from the remote server. Returns \fIundef\fR |
| 234 | upon failure. |
| 235 | .Sp |
| 236 | \&\fB\s-1NOTE\s0\fR: If you do use this method for any reason, please remember to add |
| 237 | some \f(CW\*(C`debug_print\*(C'\fR calls into your method. |
| 238 | .IP "ungetline ( \s-1TEXT\s0 )" 4 |
| 239 | .IX Item "ungetline ( TEXT )" |
| 240 | Unget a line of text from the server. |
| 241 | .IP "read_until_dot ()" 4 |
| 242 | .IX Item "read_until_dot ()" |
| 243 | Read data from the remote server until a line consisting of a single '.'. |
| 244 | Any lines starting with '..' will have one of the '.'s removed. |
| 245 | .Sp |
| 246 | Returns a reference to a list containing the lines, or \fIundef\fR upon failure. |
| 247 | .IP "tied_fh ()" 4 |
| 248 | .IX Item "tied_fh ()" |
| 249 | Returns a filehandle tied to the Net::Cmd object. After issuing a |
| 250 | command, you may read from this filehandle using \fIread()\fR or <>. The |
| 251 | filehandle will return \s-1EOF\s0 when the final dot is encountered. |
| 252 | Similarly, you may write to the filehandle in order to send data to |
| 253 | the server after issuing a commmand that expects data to be written. |
| 254 | .Sp |
| 255 | See the Net::POP3 and Net::SMTP modules for examples of this. |
| 256 | .SH "EXPORTS" |
| 257 | .IX Header "EXPORTS" |
| 258 | \&\f(CW\*(C`Net::Cmd\*(C'\fR exports six subroutines, five of these, \f(CW\*(C`CMD_INFO\*(C'\fR, \f(CW\*(C`CMD_OK\*(C'\fR, |
| 259 | \&\f(CW\*(C`CMD_MORE\*(C'\fR, \f(CW\*(C`CMD_REJECT\*(C'\fR and \f(CW\*(C`CMD_ERROR\*(C'\fR, correspond to possible results |
| 260 | of \f(CW\*(C`response\*(C'\fR and \f(CW\*(C`status\*(C'\fR. The sixth is \f(CW\*(C`CMD_PENDING\*(C'\fR. |
| 261 | .SH "AUTHOR" |
| 262 | .IX Header "AUTHOR" |
| 263 | Graham Barr <gbarr@pobox.com> |
| 264 | .SH "COPYRIGHT" |
| 265 | .IX Header "COPYRIGHT" |
| 266 | Copyright (c) 1995\-1997 Graham Barr. All rights reserved. |
| 267 | This program is free software; you can redistribute it and/or modify |
| 268 | it under the same terms as Perl itself. |
| 269 | .PP |
| 270 | \&\fI$Id: //depot/libnet/Net/Cmd.pm#28 $\fR |