Dear all,
this one is doing my head in and I'm stuck on grabbing the correct information.
I'm using expect because I have to jump between different servers to obtain my information.
When the script accesses is run from a sun solaris build device to a solaris build server this is working fine.
When I'm doing the same method towards a Redhat Linux server. (So same commands) I'm getting an unexpected output in my array.
The thing that I'm trying to accomplish is to get and check the md5 value of a file.
use strict;
use Expect;
use Term::ReadKey;
use MIME::Lite;
use File::Grep qw( fgrep fmap fdo );
use Time::Local;
sub domainmd5 {
$exp->clear_accum();
my ($exp, $domainexp, $pathfile, $file) = @_;
my (@md5subout, $md5subout);
$exp->expect( $timeout, [qr/$domainexp/ => sub {my $exp1md = shift
+; $exp1md->send ("md5sum $pathfile\r");} ], );
$exp->expect( $timeout, [qr/$domainexp/ => sub {my $exp1md = shift
+; @md5subout = $exp1md->exp_before(); } ] );
#chomp (@md5subout);
print "element0::::::::\n ---- $md5subout[
+0]----\nEND element0 ::::::::\n\n";
print "element1::::::::\n ---- $md5subout[
+1]----\nEND element1 ::::::::\n\n";
print "element2::::::::\n ---- $md5subout[
+2]----\nEND element2 ::::::::\n\n";
my @greparray = grep ( /$file/, @md5subout );
print "GREPArray::::::::\n ---- @greparray
+----\nEND ARRAY ::::::::\n\n";
my @splitarray = split (/ +/,$greparray[0]);
print "SPLITArray::::::::\n ---- @splitarr
+ay----\nEND ARRAY ::::::::\n\n";
my $md5subout = $splitarray[0];
print "Calculated at domainmd5::::-$md5sub
+out-\n";
return ($md5subout);
}
output in the array @md5subout is:
element0::::::::
in
734cc5ef88d4c8183a4cf1a16ac414c8 /c800-universalk9-mz.SPA.155-3.M5.bi
+n
[v790944@pdcd----
END element0 ::::::::
element1::::::::
---- ----
END element1 ::::::::
element2::::::::
---- ----
END element2 ::::::::
GREPArray::::::::
in
734cc5ef88d4c8183a4cf1a16ac414c8 /tftpboot/out/c800-universalk9-mz.SP
+A.155-3.M5.bin
[v790944@pdcd----
END ARRAY ::::::::
SPLITArray::::::::
in
734cc5ef88d4c8183a4cf1a16ac414c8 /tftpboot/out/c800-universalk9-mz.SPA
+.155-3.M5.bin
[v790944@pdcd----
END ARRAY ::::::::
Calculated at domainmd5::::-SPLITArray::::::::
in
734cc5ef88d4c8183a4cf1a16ac414c8 /tftpboot/out/c800-universalk9-mz.SPA
+.155-3.M5.bin
[v790944@pdcd----
END ARRAY ::::::::
Calculated at domainmd5::::-1a]~%-
The command run on the server shows the following output:
As you can see the output is only in element0 and all is in one line within the array. Yet when printing this to the terminal I'm seeing more lines so there are
special characters with the array. The only thing that is required for this part of the script is the md5 value of the file.
At last you can see that the "Calculated value at domainmd5" shows the output: -1a]~%.
This is not even in the array.
Anyone an idea?