Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The error that I am see is:sub do_ssh2 { my ($host,$server) = @_; my $username = $$server{"username"}; my $passwd = $$server{"passwd"}; my @cmdarr = $$server{"cmds"}; # <-is this correct my ($stdout, $stderr, $exit); my $ssh = Net::SSH::Perl->new($host, debug => 1); eval {$ssh->login($username, $passwd)}; if ($@) {logit ("ERROR: Wrong password for $host"); $$server{"stat +us"}="Y";} else {logit ("INFO: Logged in $host");$$server{"status"}="N";} eval {$ssh->login($username, $passwd)}; for (my $i=0; $i < @cmdarr; $i++) { my %cmdhash=$cmdarr[$i]; my $cmdname= $cmdarr[$i]{cmdname}; # doesnt work right print "\n\n$cmdarr[$i]{cmdname}\n\n"; eval{($stdout, $stderr, $exit) = $ssh->cmd($cmdname)}; if ($@) { logit ("ERROR: Some error, running $cmdname on $host"); $$server{"cmds"}[$i]{status}="N"; } else { logit ("INFO: executed $cmdname on $host"); $$server{"cmds"}[$i]{status}="Y"; $$server{"cmds"}[$i]{stdout}="$stdout"; $$server{"cmds"}[$i]{stderr}="$stderr"; $$server{"cmds"}[$i]{exit}="$exit"; } } } my %hosts=csv2hash("server_02.csv"); my $s=$hosts{"f8.lab.x.httpd.in"}; do_ssh1("f8.lab.x.httpd.in",$s);
The %hosts hash is of the following form:Reference found where even-sized list expected at ./Perl-1.pl line 121 +. Pseudo-hashes are deprecated at ./Perl-1.pl line 123.
%hosts = ( "s192.lab.x" => { status => "Y", username => "pluto", passwd => "ada232mok", cmds =>[ {cmdname => "uname",}, {cmdname => "pwd",}, ] }, "f8.lab.x.httpd.in" => { status => "Y", username => "pluto", passwd => "grs992ksj", cmds =>[ {cmdname => "uname", status => "Y", stdout => "Linux", stderr => "", exit => "0",}, {cmdname => "pwd", status => "Y", stdout => "/home/apps/plutarch", stderr => "", exit => "0",}, ] }, "sap.lab23.comp.iitd.x" => { status => "Y", username => "pluto", passwd => "ree212pkt", cmds =>[ {cmdname => "uname", status => "Y", stdout => "Linux", stderr => "", exit => "0",}, {cmdname => "pwd", status => "Y", stdout => "/home/apps/plutarch", stderr => "", exit => "0",}, ] }, );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pseudo-hashes & Hashes
by shmem (Chancellor) on Mar 16, 2008 at 23:57 UTC | |
by demerphq (Chancellor) on Mar 17, 2008 at 10:20 UTC | |
|
Re: Pseudo-hashes & Hashes
by ikegami (Patriarch) on Mar 16, 2008 at 22:50 UTC | |
|
Re: Pseudo-hashes & Hashes
by FunkyMonk (Bishop) on Mar 16, 2008 at 22:37 UTC | |
|
Re: Pseudo-hashes & Hashes
by grizzley (Chaplain) on Mar 17, 2008 at 08:33 UTC |