1N/A# Net::Cmd.pm $Id: //depot/libnet/Net/Cmd.pm#33 $
1N/A#
1N/A# Copyright (c) 1995-1997 Graham Barr <gbarr@pobox.com>. All rights reserved.
1N/A# This program is free software; you can redistribute it and/or
1N/A# modify it under the same terms as Perl itself.
1N/A
1N/Apackage Net::Cmd;
1N/A
1N/Arequire 5.001;
1N/Arequire Exporter;
1N/A
1N/Ause strict;
1N/Ause vars qw(@ISA @EXPORT $VERSION);
1N/Ause Carp;
1N/Ause Symbol 'gensym';
1N/A
1N/ABEGIN {
1N/A if ($^O eq 'os390') {
1N/A require Convert::EBCDIC;
1N/A# Convert::EBCDIC->import;
1N/A }
1N/A}
1N/A
1N/A$VERSION = "2.24";
1N/A@ISA = qw(Exporter);
1N/A@EXPORT = qw(CMD_INFO CMD_OK CMD_MORE CMD_REJECT CMD_ERROR CMD_PENDING);
1N/A
1N/Asub CMD_INFO { 1 }
1N/Asub CMD_OK { 2 }
1N/Asub CMD_MORE { 3 }
1N/Asub CMD_REJECT { 4 }
1N/Asub CMD_ERROR { 5 }
1N/Asub CMD_PENDING { 0 }
1N/A
1N/Amy %debug = ();
1N/A
1N/Amy $tr = $^O eq 'os390' ? Convert::EBCDIC->new() : undef;
1N/A
1N/Asub toebcdic
1N/A{
1N/A my $cmd = shift;
1N/A
1N/A unless (exists ${*$cmd}{'net_cmd_asciipeer'})
1N/A {
1N/A my $string = $_[0];
1N/A my $ebcdicstr = $tr->toebcdic($string);
1N/A ${*$cmd}{'net_cmd_asciipeer'} = $string !~ /^\d+/ && $ebcdicstr =~ /^\d+/;
1N/A }
1N/A
1N/A ${*$cmd}{'net_cmd_asciipeer'}
1N/A ? $tr->toebcdic($_[0])
1N/A : $_[0];
1N/A}
1N/A
1N/Asub toascii
1N/A{
1N/A my $cmd = shift;
1N/A ${*$cmd}{'net_cmd_asciipeer'}
1N/A ? $tr->toascii($_[0])
1N/A : $_[0];
1N/A}
1N/A
1N/Asub _print_isa
1N/A{
1N/A no strict qw(refs);
1N/A
1N/A my $pkg = shift;
1N/A my $cmd = $pkg;
1N/A
1N/A $debug{$pkg} ||= 0;
1N/A
1N/A my %done = ();
1N/A my @do = ($pkg);
1N/A my %spc = ( $pkg , "");
1N/A
1N/A while ($pkg = shift @do)
1N/A {
1N/A next if defined $done{$pkg};
1N/A
1N/A $done{$pkg} = 1;
1N/A
1N/A my $v = defined ${"${pkg}::VERSION"}
1N/A ? "(" . ${"${pkg}::VERSION"} . ")"
1N/A : "";
1N/A
1N/A my $spc = $spc{$pkg};
1N/A $cmd->debug_print(1,"${spc}${pkg}${v}\n");
1N/A
1N/A if(@{"${pkg}::ISA"})
1N/A {
1N/A @spc{@{"${pkg}::ISA"}} = (" " . $spc{$pkg}) x @{"${pkg}::ISA"};
1N/A unshift(@do, @{"${pkg}::ISA"});
1N/A }
1N/A }
1N/A}
1N/A
1N/Asub debug
1N/A{
1N/A @_ == 1 or @_ == 2 or croak 'usage: $obj->debug([LEVEL])';
1N/A
1N/A my($cmd,$level) = @_;
1N/A my $pkg = ref($cmd) || $cmd;
1N/A my $oldval = 0;
1N/A
1N/A if(ref($cmd))
1N/A {
1N/A $oldval = ${*$cmd}{'net_cmd_debug'} || 0;
1N/A }
1N/A else
1N/A {
1N/A $oldval = $debug{$pkg} || 0;
1N/A }
1N/A
1N/A return $oldval
1N/A unless @_ == 2;
1N/A
1N/A $level = $debug{$pkg} || 0
1N/A unless defined $level;
1N/A
1N/A _print_isa($pkg)
1N/A if($level && !exists $debug{$pkg});
1N/A
1N/A if(ref($cmd))
1N/A {
1N/A ${*$cmd}{'net_cmd_debug'} = $level;
1N/A }
1N/A else
1N/A {
1N/A $debug{$pkg} = $level;
1N/A }
1N/A
1N/A $oldval;
1N/A}
1N/A
1N/Asub message
1N/A{
1N/A @_ == 1 or croak 'usage: $obj->message()';
1N/A
1N/A my $cmd = shift;
1N/A
1N/A wantarray ? @{${*$cmd}{'net_cmd_resp'}}
1N/A : join("", @{${*$cmd}{'net_cmd_resp'}});
1N/A}
1N/A
1N/Asub debug_text { $_[2] }
1N/A
1N/Asub debug_print
1N/A{
1N/A my($cmd,$out,$text) = @_;
1N/A print STDERR $cmd,($out ? '>>> ' : '<<< '), $cmd->debug_text($out,$text);
1N/A}
1N/A
1N/Asub code
1N/A{
1N/A @_ == 1 or croak 'usage: $obj->code()';
1N/A
1N/A my $cmd = shift;
1N/A
1N/A ${*$cmd}{'net_cmd_code'} = "000"
1N/A unless exists ${*$cmd}{'net_cmd_code'};
1N/A
1N/A ${*$cmd}{'net_cmd_code'};
1N/A}
1N/A
1N/Asub status
1N/A{
1N/A @_ == 1 or croak 'usage: $obj->status()';
1N/A
1N/A my $cmd = shift;
1N/A
1N/A substr(${*$cmd}{'net_cmd_code'},0,1);
1N/A}
1N/A
1N/Asub set_status
1N/A{
1N/A @_ == 3 or croak 'usage: $obj->set_status(CODE, MESSAGE)';
1N/A
1N/A my $cmd = shift;
1N/A my($code,$resp) = @_;
1N/A
1N/A $resp = [ $resp ]
1N/A unless ref($resp);
1N/A
1N/A (${*$cmd}{'net_cmd_code'},${*$cmd}{'net_cmd_resp'}) = ($code, $resp);
1N/A
1N/A 1;
1N/A}
1N/A
1N/Asub command
1N/A{
1N/A my $cmd = shift;
1N/A
1N/A unless (defined fileno($cmd))
1N/A {
1N/A $cmd->set_status("599", "Connection closed");
1N/A return $cmd;
1N/A }
1N/A
1N/A
1N/A $cmd->dataend()
1N/A if(exists ${*$cmd}{'net_cmd_need_crlf'});
1N/A
1N/A if (scalar(@_))
1N/A {
1N/A local $SIG{PIPE} = 'IGNORE' unless $^O eq 'MacOS';
1N/A
1N/A my $str = join(" ", map { /\n/ ? do { my $n = $_; $n =~ tr/\n/ /; $n } : $_; } @_);
1N/A $str = $cmd->toascii($str) if $tr;
1N/A $str .= "\015\012";
1N/A
1N/A my $len = length $str;
1N/A my $swlen;
1N/A
1N/A $cmd->close
1N/A unless (defined($swlen = syswrite($cmd,$str,$len)) && $swlen == $len);
1N/A
1N/A $cmd->debug_print(1,$str)
1N/A if($cmd->debug);
1N/A
1N/A ${*$cmd}{'net_cmd_resp'} = []; # the response
1N/A ${*$cmd}{'net_cmd_code'} = "000"; # Made this one up :-)
1N/A }
1N/A
1N/A $cmd;
1N/A}
1N/A
1N/Asub ok
1N/A{
1N/A @_ == 1 or croak 'usage: $obj->ok()';
1N/A
1N/A my $code = $_[0]->code;
1N/A 0 < $code && $code < 400;
1N/A}
1N/A
1N/Asub unsupported
1N/A{
1N/A my $cmd = shift;
1N/A
1N/A ${*$cmd}{'net_cmd_resp'} = [ 'Unsupported command' ];
1N/A ${*$cmd}{'net_cmd_code'} = 580;
1N/A 0;
1N/A}
1N/A
1N/Asub getline
1N/A{
1N/A my $cmd = shift;
1N/A
1N/A ${*$cmd}{'net_cmd_lines'} ||= [];
1N/A
1N/A return shift @{${*$cmd}{'net_cmd_lines'}}
1N/A if scalar(@{${*$cmd}{'net_cmd_lines'}});
1N/A
1N/A my $partial = defined(${*$cmd}{'net_cmd_partial'})
1N/A ? ${*$cmd}{'net_cmd_partial'} : "";
1N/A my $fd = fileno($cmd);
1N/A
1N/A return undef
1N/A unless defined $fd;
1N/A
1N/A my $rin = "";
1N/A vec($rin,$fd,1) = 1;
1N/A
1N/A my $buf;
1N/A
1N/A until(scalar(@{${*$cmd}{'net_cmd_lines'}}))
1N/A {
1N/A my $timeout = $cmd->timeout || undef;
1N/A my $rout;
1N/A if (select($rout=$rin, undef, undef, $timeout))
1N/A {
1N/A unless (sysread($cmd, $buf="", 1024))
1N/A {
1N/A carp(ref($cmd) . ": Unexpected EOF on command channel")
1N/A if $cmd->debug;
1N/A $cmd->close;
1N/A return undef;
1N/A }
1N/A
1N/A substr($buf,0,0) = $partial; ## prepend from last sysread
1N/A
1N/A my @buf = split(/\015?\012/, $buf, -1); ## break into lines
1N/A
1N/A $partial = pop @buf;
1N/A
1N/A push(@{${*$cmd}{'net_cmd_lines'}}, map { "$_\n" } @buf);
1N/A
1N/A }
1N/A else
1N/A {
1N/A carp("$cmd: Timeout") if($cmd->debug);
1N/A return undef;
1N/A }
1N/A }
1N/A
1N/A ${*$cmd}{'net_cmd_partial'} = $partial;
1N/A
1N/A if ($tr)
1N/A {
1N/A foreach my $ln (@{${*$cmd}{'net_cmd_lines'}})
1N/A {
1N/A $ln = $cmd->toebcdic($ln);
1N/A }
1N/A }
1N/A
1N/A shift @{${*$cmd}{'net_cmd_lines'}};
1N/A}
1N/A
1N/Asub ungetline
1N/A{
1N/A my($cmd,$str) = @_;
1N/A
1N/A ${*$cmd}{'net_cmd_lines'} ||= [];
1N/A unshift(@{${*$cmd}{'net_cmd_lines'}}, $str);
1N/A}
1N/A
1N/Asub parse_response
1N/A{
1N/A return ()
1N/A unless $_[1] =~ s/^(\d\d\d)(.?)//o;
1N/A ($1, $2 eq "-");
1N/A}
1N/A
1N/Asub response
1N/A{
1N/A my $cmd = shift;
1N/A my($code,$more) = (undef) x 2;
1N/A
1N/A ${*$cmd}{'net_cmd_resp'} ||= [];
1N/A
1N/A while(1)
1N/A {
1N/A my $str = $cmd->getline();
1N/A
1N/A return CMD_ERROR
1N/A unless defined($str);
1N/A
1N/A $cmd->debug_print(0,$str)
1N/A if ($cmd->debug);
1N/A
1N/A ($code,$more) = $cmd->parse_response($str);
1N/A unless(defined $code)
1N/A {
1N/A $cmd->ungetline($str);
1N/A last;
1N/A }
1N/A
1N/A ${*$cmd}{'net_cmd_code'} = $code;
1N/A
1N/A push(@{${*$cmd}{'net_cmd_resp'}},$str);
1N/A
1N/A last unless($more);
1N/A }
1N/A
1N/A substr($code,0,1);
1N/A}
1N/A
1N/Asub read_until_dot
1N/A{
1N/A my $cmd = shift;
1N/A my $fh = shift;
1N/A my $arr = [];
1N/A
1N/A while(1)
1N/A {
1N/A my $str = $cmd->getline() or return undef;
1N/A
1N/A $cmd->debug_print(0,$str)
1N/A if ($cmd->debug & 4);
1N/A
1N/A last if($str =~ /^\.\r?\n/o);
1N/A
1N/A $str =~ s/^\.\././o;
1N/A
1N/A if (defined $fh)
1N/A {
1N/A print $fh $str;
1N/A }
1N/A else
1N/A {
1N/A push(@$arr,$str);
1N/A }
1N/A }
1N/A
1N/A $arr;
1N/A}
1N/A
1N/Asub datasend
1N/A{
1N/A my $cmd = shift;
1N/A my $arr = @_ == 1 && ref($_[0]) ? $_[0] : \@_;
1N/A my $line = join("" ,@$arr);
1N/A
1N/A return 0 unless defined(fileno($cmd));
1N/A
1N/A unless (length $line) {
1N/A # Even though we are not sending anything, the fact we were
1N/A # called means that dataend needs to be called before the next
1N/A # command, which happens of net_cmd_need_crlf exists
1N/A ${*$cmd}{'net_cmd_need_crlf'} ||= 0;
1N/A return 1;
1N/A }
1N/A
1N/A if($cmd->debug) {
1N/A foreach my $b (split(/\n/,$line)) {
1N/A $cmd->debug_print(1, "$b\n");
1N/A }
1N/A }
1N/A
1N/A $line =~ s/\r?\n/\r\n/sg;
1N/A $line =~ tr/\r\n/\015\012/ unless "\r" eq "\015";
1N/A
1N/A $line =~ s/(\012\.)/$1./sog;
1N/A $line =~ s/^\./../ unless ${*$cmd}{'net_cmd_need_crlf'};
1N/A
1N/A ${*$cmd}{'net_cmd_need_crlf'} = substr($line,-1,1) ne "\012";
1N/A
1N/A my $len = length($line);
1N/A my $offset = 0;
1N/A my $win = "";
1N/A vec($win,fileno($cmd),1) = 1;
1N/A my $timeout = $cmd->timeout || undef;
1N/A
1N/A local $SIG{PIPE} = 'IGNORE' unless $^O eq 'MacOS';
1N/A
1N/A while($len)
1N/A {
1N/A my $wout;
1N/A if (select(undef,$wout=$win, undef, $timeout) > 0)
1N/A {
1N/A my $w = syswrite($cmd, $line, $len, $offset);
1N/A unless (defined($w))
1N/A {
1N/A carp("$cmd: $!") if $cmd->debug;
1N/A return undef;
1N/A }
1N/A $len -= $w;
1N/A $offset += $w;
1N/A }
1N/A else
1N/A {
1N/A carp("$cmd: Timeout") if($cmd->debug);
1N/A return undef;
1N/A }
1N/A }
1N/A
1N/A 1;
1N/A}
1N/A
1N/Asub rawdatasend
1N/A{
1N/A my $cmd = shift;
1N/A my $arr = @_ == 1 && ref($_[0]) ? $_[0] : \@_;
1N/A my $line = join("" ,@$arr);
1N/A
1N/A return 0 unless defined(fileno($cmd));
1N/A
1N/A return 1
1N/A unless length($line);
1N/A
1N/A if($cmd->debug)
1N/A {
1N/A my $b = "$cmd>>> ";
1N/A print STDERR $b,join("\n$b",split(/\n/,$line)),"\n";
1N/A }
1N/A
1N/A my $len = length($line);
1N/A my $offset = 0;
1N/A my $win = "";
1N/A vec($win,fileno($cmd),1) = 1;
1N/A my $timeout = $cmd->timeout || undef;
1N/A
1N/A local $SIG{PIPE} = 'IGNORE' unless $^O eq 'MacOS';
1N/A while($len)
1N/A {
1N/A my $wout;
1N/A if (select(undef,$wout=$win, undef, $timeout) > 0)
1N/A {
1N/A my $w = syswrite($cmd, $line, $len, $offset);
1N/A unless (defined($w))
1N/A {
1N/A carp("$cmd: $!") if $cmd->debug;
1N/A return undef;
1N/A }
1N/A $len -= $w;
1N/A $offset += $w;
1N/A }
1N/A else
1N/A {
1N/A carp("$cmd: Timeout") if($cmd->debug);
1N/A return undef;
1N/A }
1N/A }
1N/A
1N/A 1;
1N/A}
1N/A
1N/Asub dataend
1N/A{
1N/A my $cmd = shift;
1N/A
1N/A return 0 unless defined(fileno($cmd));
1N/A
1N/A return 1
1N/A unless(exists ${*$cmd}{'net_cmd_need_crlf'});
1N/A
1N/A local $SIG{PIPE} = 'IGNORE' unless $^O eq 'MacOS';
1N/A syswrite($cmd,"\015\012",2)
1N/A if ${*$cmd}{'net_cmd_need_crlf'};
1N/A
1N/A $cmd->debug_print(1, ".\n")
1N/A if($cmd->debug);
1N/A
1N/A syswrite($cmd,".\015\012",3);
1N/A
1N/A delete ${*$cmd}{'net_cmd_need_crlf'};
1N/A
1N/A $cmd->response() == CMD_OK;
1N/A}
1N/A
1N/A# read and write to tied filehandle
1N/Asub tied_fh {
1N/A my $cmd = shift;
1N/A ${*$cmd}{'net_cmd_readbuf'} = '';
1N/A my $fh = gensym();
1N/A tie *$fh,ref($cmd),$cmd;
1N/A return $fh;
1N/A}
1N/A
1N/A# tie to myself
1N/Asub TIEHANDLE {
1N/A my $class = shift;
1N/A my $cmd = shift;
1N/A return $cmd;
1N/A}
1N/A
1N/A# Tied filehandle read. Reads requested data length, returning
1N/A# end-of-file when the dot is encountered.
1N/Asub READ {
1N/A my $cmd = shift;
1N/A my ($len,$offset) = @_[1,2];
1N/A return unless exists ${*$cmd}{'net_cmd_readbuf'};
1N/A my $done = 0;
1N/A while (!$done and length(${*$cmd}{'net_cmd_readbuf'}) < $len) {
1N/A ${*$cmd}{'net_cmd_readbuf'} .= $cmd->getline() or return;
1N/A $done++ if ${*$cmd}{'net_cmd_readbuf'} =~ s/^\.\r?\n\Z//m;
1N/A }
1N/A
1N/A $_[0] = '';
1N/A substr($_[0],$offset+0) = substr(${*$cmd}{'net_cmd_readbuf'},0,$len);
1N/A substr(${*$cmd}{'net_cmd_readbuf'},0,$len) = '';
1N/A delete ${*$cmd}{'net_cmd_readbuf'} if $done;
1N/A
1N/A return length $_[0];
1N/A}
1N/A
1N/Asub READLINE {
1N/A my $cmd = shift;
1N/A # in this context, we use the presence of readbuf to
1N/A # indicate that we have not yet reached the eof
1N/A return unless exists ${*$cmd}{'net_cmd_readbuf'};
1N/A my $line = $cmd->getline;
1N/A return if $line =~ /^\.\r?\n/;
1N/A $line;
1N/A}
1N/A
1N/Asub PRINT {
1N/A my $cmd = shift;
1N/A my ($buf,$len,$offset) = @_;
1N/A $len ||= length ($buf);
1N/A $offset += 0;
1N/A return unless $cmd->datasend(substr($buf,$offset,$len));
1N/A ${*$cmd}{'net_cmd_sending'}++; # flag that we should call dataend()
1N/A return $len;
1N/A}
1N/A
1N/Asub CLOSE {
1N/A my $cmd = shift;
1N/A my $r = exists(${*$cmd}{'net_cmd_sending'}) ? $cmd->dataend : 1;
1N/A delete ${*$cmd}{'net_cmd_readbuf'};
1N/A delete ${*$cmd}{'net_cmd_sending'};
1N/A $r;
1N/A}
1N/A
1N/A1;
1N/A
1N/A__END__
1N/A
1N/A
1N/A=head1 NAME
1N/A
1N/ANet::Cmd - Network Command class (as used by FTP, SMTP etc)
1N/A
1N/A=head1 SYNOPSIS
1N/A
1N/A use Net::Cmd;
1N/A
1N/A @ISA = qw(Net::Cmd);
1N/A
1N/A=head1 DESCRIPTION
1N/A
1N/AC<Net::Cmd> is a collection of methods that can be inherited by a sub class
1N/Aof C<IO::Handle>. These methods implement the functionality required for a
1N/Acommand based protocol, for example FTP and SMTP.
1N/A
1N/A=head1 USER METHODS
1N/A
1N/AThese methods provide a user interface to the C<Net::Cmd> object.
1N/A
1N/A=over 4
1N/A
1N/A=item debug ( VALUE )
1N/A
1N/ASet the level of debug information for this object. If C<VALUE> is not given
1N/Athen the current state is returned. Otherwise the state is changed to
1N/AC<VALUE> and the previous state returned.
1N/A
1N/ADifferent packages
1N/Amay implement different levels of debug but a non-zero value results in
1N/Acopies of all commands and responses also being sent to STDERR.
1N/A
1N/AIf C<VALUE> is C<undef> then the debug level will be set to the default
1N/Adebug level for the class.
1N/A
1N/AThis method can also be called as a I<static> method to set/get the default
1N/Adebug level for a given class.
1N/A
1N/A=item message ()
1N/A
1N/AReturns the text message returned from the last command
1N/A
1N/A=item code ()
1N/A
1N/AReturns the 3-digit code from the last command. If a command is pending
1N/Athen the value 0 is returned
1N/A
1N/A=item ok ()
1N/A
1N/AReturns non-zero if the last code value was greater than zero and
1N/Aless than 400. This holds true for most command servers. Servers
1N/Awhere this does not hold may override this method.
1N/A
1N/A=item status ()
1N/A
1N/AReturns the most significant digit of the current status code. If a command
1N/Ais pending then C<CMD_PENDING> is returned.
1N/A
1N/A=item datasend ( DATA )
1N/A
1N/ASend data to the remote server, converting LF to CRLF. Any line starting
1N/Awith a '.' will be prefixed with another '.'.
1N/AC<DATA> may be an array or a reference to an array.
1N/A
1N/A=item dataend ()
1N/A
1N/AEnd the sending of data to the remote server. This is done by ensuring that
1N/Athe data already sent ends with CRLF then sending '.CRLF' to end the
1N/Atransmission. Once this data has been sent C<dataend> calls C<response> and
1N/Areturns true if C<response> returns CMD_OK.
1N/A
1N/A=back
1N/A
1N/A=head1 CLASS METHODS
1N/A
1N/AThese methods are not intended to be called by the user, but used or
1N/Aover-ridden by a sub-class of C<Net::Cmd>
1N/A
1N/A=over 4
1N/A
1N/A=item debug_print ( DIR, TEXT )
1N/A
1N/APrint debugging information. C<DIR> denotes the direction I<true> being
1N/Adata being sent to the server. Calls C<debug_text> before printing to
1N/ASTDERR.
1N/A
1N/A=item debug_text ( TEXT )
1N/A
1N/AThis method is called to print debugging information. TEXT is
1N/Athe text being sent. The method should return the text to be printed
1N/A
1N/AThis is primarily meant for the use of modules such as FTP where passwords
1N/Aare sent, but we do not want to display them in the debugging information.
1N/A
1N/A=item command ( CMD [, ARGS, ... ])
1N/A
1N/ASend a command to the command server. All arguments a first joined with
1N/Aa space character and CRLF is appended, this string is then sent to the
1N/Acommand server.
1N/A
1N/AReturns undef upon failure
1N/A
1N/A=item unsupported ()
1N/A
1N/ASets the status code to 580 and the response text to 'Unsupported command'.
1N/AReturns zero.
1N/A
1N/A=item response ()
1N/A
1N/AObtain a response from the server. Upon success the most significant digit
1N/Aof the status code is returned. Upon failure, timeout etc., I<undef> is
1N/Areturned.
1N/A
1N/A=item parse_response ( TEXT )
1N/A
1N/AThis method is called by C<response> as a method with one argument. It should
1N/Areturn an array of 2 values, the 3-digit status code and a flag which is true
1N/Awhen this is part of a multi-line response and this line is not the list.
1N/A
1N/A=item getline ()
1N/A
1N/ARetrieve one line, delimited by CRLF, from the remote server. Returns I<undef>
1N/Aupon failure.
1N/A
1N/AB<NOTE>: If you do use this method for any reason, please remember to add
1N/Asome C<debug_print> calls into your method.
1N/A
1N/A=item ungetline ( TEXT )
1N/A
1N/AUnget a line of text from the server.
1N/A
1N/A=item rawdatasend ( DATA )
1N/A
1N/ASend data to the remote server without performing any conversions. C<DATA>
1N/Ais a scalar.
1N/A
1N/A=item read_until_dot ()
1N/A
1N/ARead data from the remote server until a line consisting of a single '.'.
1N/AAny lines starting with '..' will have one of the '.'s removed.
1N/A
1N/AReturns a reference to a list containing the lines, or I<undef> upon failure.
1N/A
1N/A=item tied_fh ()
1N/A
1N/AReturns a filehandle tied to the Net::Cmd object. After issuing a
1N/Acommand, you may read from this filehandle using read() or <>. The
1N/Afilehandle will return EOF when the final dot is encountered.
1N/ASimilarly, you may write to the filehandle in order to send data to
1N/Athe server after issuing a commmand that expects data to be written.
1N/A
1N/ASee the Net::POP3 and Net::SMTP modules for examples of this.
1N/A
1N/A=back
1N/A
1N/A=head1 EXPORTS
1N/A
1N/AC<Net::Cmd> exports six subroutines, five of these, C<CMD_INFO>, C<CMD_OK>,
1N/AC<CMD_MORE>, C<CMD_REJECT> and C<CMD_ERROR>, correspond to possible results
1N/Aof C<response> and C<status>. The sixth is C<CMD_PENDING>.
1N/A
1N/A=head1 AUTHOR
1N/A
1N/AGraham Barr <gbarr@pobox.com>
1N/A
1N/A=head1 COPYRIGHT
1N/A
1N/ACopyright (c) 1995-1997 Graham Barr. All rights reserved.
1N/AThis program is free software; you can redistribute it and/or modify
1N/Ait under the same terms as Perl itself.
1N/A
1N/A=for html <hr>
1N/A
1N/AI<$Id: //depot/libnet/Net/Cmd.pm#33 $>
1N/A
1N/A=cut