#!/usr/bin/perl use strict; # https://www.perlmonks.org/?node_id=11155061 use warnings; use Net::Telnet (); my $host='192.168.1.13'; # FIXME my $t; my $oid; {$t = new Net::Telnet (Timeout => 10,Input_log => "received_data.txt" , Port => 12345, # FIXME 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## my ($returnedvalue, $match) = $t->waitfor('/OK/i'); $returnedvalue =~ tr/0-9//cd; # delete everything except digits print "this is what I think you are looking for: $returnedvalue\n"; } $t->close() #### this is what I think you are looking for: 2