CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Telnet problems

 



Secalles
Novice

Nov 8, 2010, 6:41 AM

Post #1 of 4 (514 views)
Telnet problems Can't Post

Hiii , I started to using perl last week cuz we need a script that connects to a modem via telnet and get his status.

I tryed this:

use Net::Telnet;

$myip="192.168.72.7";
$comando="<20/cid?";

$telnet = Net::Telnet->new (
Timeout => 15,
Errmode =>'die',);
$telnet->open( Host => $myip );

$telnet->waitfor('/Enter Name/i');
$telnet->print('XXX');
$telnet->waitfor('/Enter Password/i');
$telnet->print('XXX');
$telnet->waitfor('/->/i');
$output = $telnet->print('/$comando/i');
print "$output \n";




This program works but doesnt print what i want ,

it prints : " $output = 1"

i think the problem is the "/" but i dont kwon how to solve it

-----------------------------------------------------------
in the telnet i have this

Enter name: XXX


Enter password: XXX


Name and Password accepted. Please review your modem manual for command syntax.


(Q=Quit) Telnet--><20/cid?

>0020/CID=PI-147 MORRO CABECA DO TEMPO

$comando in my script is one of the commands that i need to have backup and all of the commands have "/"
but for now i just want to print it !

I apreciate any help rs!


rovf
Veteran

Nov 9, 2010, 6:45 AM

Post #2 of 4 (500 views)
Re: [Secalles] Telnet problems [In reply to] Can't Post

I don't know whether this alreay explains your observation, but:

$output = $telnet->print('/$comando/i');

You are using single quotes instead of double ones, which means that $comando won't be substituted.


Secalles
Novice

Nov 12, 2010, 4:59 AM

Post #3 of 4 (476 views)
Re: [Secalles] Telnet problems [In reply to] Can't Post

well i found the problem

use Net::Telnet;

$myip="192.168.72.7";
$comando="<20/cid?";

$telnet = Net::Telnet->new (
Timeout => 15,
Errmode =>'die',);
$telnet->open( Host => $myip );

$telnet->waitfor('/Enter Name/i');
$telnet->print('XXX');
$telnet->waitfor('/Enter Password/i');
$telnet->print('XXX');
$telnet->waitfor('/->/i');
$telnet->print($comando);
@output = $telnet->waitfor('/->/i');
print "@output \n";


----------------------------------------

just a few stuff that i didnt know , the OUTPUT should be an array an like the other guy said i used single ' , but i need " ...


I m having a diferente kind of problem now ... one of the comands that i send in the telnet via hyperterminal returns this :

(Q=Quit) Telnet--><20/rns?

>0020/RNS=
05.605.71.21.3121110045400
05.605.71.21.2121110050400
05.605.71.21.2121110051400
05.605.61.21.2121110052400
05.605.71.21.2121110053400

(all lines that i need)


(Q=Quit) Telnet-->

when i open cmd and telnet and put the command it displays this:

(Q=Quit) Telnet--><20/rns?
05.105.20.21.9121110081532 ( Just one line )

but when i put it in the perl script ( i just change the $comando to $comando="<20/rns?")

perl returns me this:

<20/rns?
04.804.90.00.0121110085403

(Q=Quit) Telnet- ->

(just one line)

i need the other lines too , can anyone help me with that?


Secalles
Novice

Nov 29, 2010, 5:39 AM

Post #4 of 4 (447 views)
Re: [Secalles] Telnet problems [In reply to] Can't Post

since nobody answer ... if someone needs anything about telnet look this http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm

and i solved my problem using this

Code
		$telnet = new Net::Telnet ( Timeout=>10, Errmode=>'return',Input_Log => "$name.txt"); 
$telnet->open( Host => '$ip',
Port => $porta);


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives