Phoenix.pm: Net::Telnet

johngnub at cox.net johngnub at cox.net
Wed Jan 14 13:24:05 CST 2004


The cmd method will hold data till the next prompt is found; So the distance of a cmd is the measure of prompt to prompt. 

If you encounter a nasty prompt try this;
Issue a cmd to set the prompt right away.
 @lines = $tango->cmd("PS1='foo';stty kill '^U';export TERM=vt100") 

Now you can set the prompt to 'foo'

Prompt  => '/foo/'o'

Or from the perldoc Net::Telnet:

" Use a combination of "print()" and "waitfor()" as an
alternative to "login()" or "cmd()" when they don't 
what you want. 

EXAMPLE, note the '/ is a gregex...

$t->waitfor('/continue:.*$/');
$t->print("");


Examples on request....JB









Or get angery and find out just what that "non-prompt is"
>From the perldoc get - read block of data
               $data = $obj->get([Binmode    => $mode,]
                                 [Errmode    => $errmode,]
                                 [Telnetmode => $mode,]
                                 [Timeout    => $secs,]);
 
           This method reads a block of data from the object and
           returns it along with any buffered data.  If no
           buffered data is available to return, it will wait for
           data to read using the timeout specified in the
           object.  You can override that timeout using $secs.
           Also see "timeout()".  If buffered data is available
           to return, it also checks for a block of data that can
           be immediately read.




> 
> From: Matt Alexander <m at pdxlug.org>
> Date: 2004/01/14 Wed AM 10:06:56 EST
> To: PHXPERL <phoenix-pm-list at happyfunball.pm.org>
> Subject: Phoenix.pm: Net::Telnet
> 
> I'm trying to use Net::Telnet to connect to a device that simply outputs
> data after a connection is made.  There's no prompt and there's no
> indication of when it's done sending data, however I know that after about
> 10 seconds that I should have received all the data that was available.  I
> then want to save all the output from this device to a log file.
> 
> I think the problem with my script is that it's looking for a prompt from
> the device.  I've tried setting Prompt => undef and Prompt => "", but
> these both generate warnings and I never retrieve any data.
> 
> Any suggestions?
> Thanks,
> ~M
> 




More information about the Phoenix-pm mailing list