Net::Telnet & Local Directors 
Author Message
 Net::Telnet & Local Directors


>> >Thank you for your response Gianluca,
>> >In my example is use

>> >where in your example, you use

>> >The reason I am using print, insted of cmd is that it keeps timing out
>> >when I use cmd.

>> Then the reason may be that you never match the Telnet-prompt you have
>> set up, and "cmd" is waiting for. You better start debugging and see
>> how far you get in your script by using input_log() and/or dump_log().

>What I mean is that my prompt contains a '-' hypen in it: ie. host-name>

When I try to use this module towards my Linux test-servers I might
use the examples out-of-the-box ....

For a client I once tried to use this module to telnet to an HP-UX
server, and that was certainly not easy ;-/
I did a manuel telnet towards the server parallell with reading my
debugging files, THAT helped alot :-)

_Maybe_ my solution might put you on right track .....
Hint: Do one step at a time.  The feedback you get back usually tells
that the _previous_ command/function/expectation didn't work!

#!/usr/bin/perl -w
use strict;
use Net::Telnet();
my $t = new Net::Telnet(Timeout=>6,
# Should here match:
# Prompt: "maci_1<space><number>:<space><end_of_prompt>"
# Hint: Try to match from right to left, more precisely for each
# try ....
  Prompt     => '/maci_1 [0-9]+: $/');
# Hint: use debugging (For my client, my script needed to
# be able to run on an MS OS machine):
my $fh_input = $t->input_log("c:/temp/input_log.txt");
my $fh_dump = $t->dump_log("c:/temp/dump_log.hex");
# Well, port=23 _is_ default
$t->open(Host=>"",Port=>23) || die "No host\n";
# NB: I could not use this easy standard approach:
###$t->login(Name=>"myloginname",Password=>'mysecretpassword') || die
"No logon\n";
# Instead I tried:
# (Strangely I had to put in these 'getlines' to make the script
# proceed)
# Before getting prompt I had to answer term-modus:
$t->waitfor(Match=>'/TERM = \(hp\)/');
# NB: I had to put in a blank line to get prompt!
# My test-command


# Strangely I got some rubbish chars, so I could not just
# do this to print out result,

#but that was done using some s/// tricks ... :-)
K?re Olai Lindbach

Wed, 26 Jan 2005 17:13:27 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Net::Telnet & Net::Ping

2. Net::Telnet && keeping conections alive

3. Net::Telnet & file uploading

4. Net::Telnet & Sendmail

5. Net::Telnet-ing problem to Solaris telnet server

6. Net::Telnet 3.03: drain a telnet buffer

7. Telnet-Client with Net::Telnet

8. Telnet cmd, Net::Telnet

9. keeping Telnet alive with Net::Telnet

10. Net::Telnet -like module without telnet

11. Net::Telnet and Net::SSH or ssh ?

12. telnet with no local echo?


Powered by phpBB® Forum Software