mikebailey has asked for the wisdom of the Perl Monks concerning the following question:
Having difficult time getting a response from my perl script when using Net::Telnet. The server is not actually a telnet server, but responses to print command from perl. I do get all the correct responses in the "recieved_data.txt" file, but need the returned value.
#!/usr/bin/perl use Net::Telnet (); $host='192.168.1.181'; {$t = new Net::Telnet (Timeout => 10,Input_log => "received_data.txt" +, Prompt => '/bash\$ $/'); $t->open($host); $t->print("AT"); #this is just used to make sure it connects## $t->waitfor('/AT/'); #this is just an echo back of what is sent## $t->waitfor('/OK/i'); #send this to say I'm ready## } {$t->print("AT%23=1234"); #This basically the password to the system# +# $t->waitfor('/AT%23=1234/i'); #Echo back## $t->waitfor('/OK/i'); } { $oid = $t->print("AT1122"); #This is the command to see the state## $oid = $t->waitfor('/AT1122/i'); #Echo back## $oid = $t->waitfor('//'); #this could be 0,1,2...need to converto oid +### #Need this value to check state in SNMP## $t->waitfor('/OK/i'); } $t->close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Telnet responses
by choroba (Cardinal) on Oct 19, 2023 at 17:39 UTC | |
by mikebailey (Novice) on Oct 19, 2023 at 18:51 UTC | |
|
Re: Telnet responses
by cavac (Prior) on Oct 20, 2023 at 08:02 UTC | |
by haukex (Archbishop) on Oct 20, 2023 at 11:15 UTC | |
by cavac (Prior) on Oct 20, 2023 at 12:29 UTC | |
|
Re: Telnet responses
by tybalt89 (Monsignor) on Oct 20, 2023 at 20:23 UTC | |
by mikebailey (Novice) on Oct 20, 2023 at 21:29 UTC | |
by mikebailey (Novice) on Oct 21, 2023 at 13:57 UTC |