I wrote a small program using Expect.pm to read the output of 'ls -l' on a remote host and then write into a local logfile.
Somehow, certain weird char's are also automatically written into the log. This is my first time using Expect.pm and I am not sure if my problem is related to Expect.pm.
Here is a small piece of my codes:
The screen output is:
As you can see here, they are all CLEAN!
Below is the contents of the logfile:
They are also clean. However, when I open the logfile through vim. The contents looks aweful:
Where do those weird chars (in red) come from? Does it have anything to do with Expect.pm? How to get rid of them?
And lastly, for your reference, below is the output of 'ls -l' on the remote host 192.168.1.5:
Many thanks for you help!!
Somehow, certain weird char's are also automatically written into the log. This is my first time using Expect.pm and I am not sure if my problem is related to Expect.pm.
Here is a small piece of my codes:
Code:
# @buf contains the output of 'ls -l' on a remote host 192.168.1.5
foreach my $e (@buf) {
$e =~ s/^\s+//;
$e =~ s/\s+$//;
my @tmp = split(/\s+/, $e);
if($#tmp == 8 && $tmp[$#tmp] =~ /idx/) {
$flist{$tmp[$#tmp]} = $tmp[4];
if($cnt < 2) {
print "$cnt. $server, #$tmp[$#tmp]#, $tmp[4]\n";
print H1 "$cnt. $server, #$tmp[$#tmp]#, $tmp[4]\n";
}
$cnt++;
}
}
The screen output is:
Code:
0. 192.168.1.5, #00d786312b6a16d6_config.3.0.idx#, 393216
1. 192.168.1.5, #00d786312b6a16d6_correlations.3.0.idx#, 10616832
As you can see here, they are all CLEAN!
Below is the contents of the logfile:
Code:
$ cat info.txt
0. 192.168.1.5, #00d786312b6a16d6_config.3.0.idx#, 393216
1. 192.168.1.5, #00d786312b6a16d6_correlations.3.0.idx#, 10616832
Code:
0. 192.168.1.5, #[COLOR=red]^[[00m[/color]00d786312b6a16d6_config.3.0.idx[COLOR=red]^[[00m[/color]#, 393216
1. 192.168.1.5, #[COLOR=red]^[[00m[/color]00d786312b6a16d6_correlations.3.0.idx[COLOR=red]^[[00m[/color]#, 10616832
Where do those weird chars (in red) come from? Does it have anything to do with Expect.pm? How to get rid of them?
And lastly, for your reference, below is the output of 'ls -l' on the remote host 192.168.1.5:
Code:
% ls -l 00d786312b6a16d6_config.3.0.idx 00d786312b6a16d6_correlations.3.0.idx
-rw-r--r-- 1 abc abc 393216 Jan 31 2011 00d786312b6a16d6_config.3.0.idx
-rw-r--r-- 1 abc abc 10616832 Jan 31 2011 00d786312b6a16d6_correlations.3.0.idx
Many thanks for you help!!