I wrote a Perl script to log into my telnet server and send the output to a text file, but I am getting a ton of weird characters within each sentence of output that I want to parse\take out. All I want to do is read in the text file and remove the unwanted characters line by line to display the correct output.
EDIT:
Here are the first lines from my text file,the word data indicates the information I want and as you can see it is wrapped in the characters that I want to remove:
data data dat data data[1;1H[24;0H[K7[1;1H[0;7mdata data data da
+ta data[0m8[23;0H[0;7m
+ [0m[23;0H[2;1H[K[B[K[B[K[B
+[K[B[K[B[K[B[K[B[K[B[K[B[K[B[K[B[K[B[K[B[K[B[K
+[B[K[B[K[B[K[B[K[B[K[B[K[B7[1;65H[0;7m Page 1
+[0m8[3;1H[3;23
[5;1Hdata data [5;47Hdata: data data data data,
+data
[6;9Hdata: data
[7;4Hdata data data data [7;49Hdata data data data
HERE IS MY SCRIPT:(Which is working perfectly)
my ($hostname, $line, $password, $pop, $username);
$hostname = "local_host";
$username = "name";
$password = "pass";
$file = "log_file";
$file1 = "dump_log";
use Net::Telnet ();
$pop = new Net::Telnet (Telnetmode => 1, Input_log => $file, dump_log
+=> $file1);
$pop->open(Host => $hostname,Port => port#);
$pop->waitfor('/login: $/i');
$pop->print($username);
$pop->waitfor('/password: $/i');
$pop->print($password);
$pop->print("terminal type");
$pop->waitfor('/Command: $/i');
$pop->print("terminal_command");
$line = $pop->get;
print $line;
open FILE, "data.txt" or die $!;
print FILE $line;
close FILE;