suresh3566 has asked for the wisdom of the Perl Monks concerning the following question:
Hi Friends, I have written a CGI script to check uptime on remote server using html which calls perl CGI script.
cat mainriinfo.cgi #!/usr/bin/perl use strict; use warnings; use Net::SSH2::Perl; my $user = "root"; my $password = "adxyusc12"; my @hosts = qw(172.23.12.110); foreach my $host (@hosts){ my $cmd = "/usr/bin/uptime"; my $ssh = Net::SSH2::Perl->new( $host, port => 22); $ssh->login($user,$password); my($out) = $ssh->cmd($cmd); my ($time,$uptime) = (split /\s+/,$out)[1,3]; chop $uptime; print "$host has been up $uptime\n"; } print <<END; <html> <head><title>Hello </title></head> <body> <p>Script Finished</p> </body> </html> END
After executing, I am getting below error:
[Wed Jul 20 11:45:40 2016] [error] [client 172.17.17.43] (8)Exec forma +t error: exec of '/var/www/html/mainriinfo.cgi' failed, referer: http +://172.23.12.110/getriinfo.html [Wed Jul 20 11:45:40 2016] [error] [client 172.17.17.43] Premature end + of script headers: mainriinfo.cgi, referer: http://172.23.12.110/get +riinfo.html
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::SSH2 CGI script fails
by salva (Canon) on Jul 20, 2016 at 07:00 UTC | |
|
Re: Net::SSH2 CGI script fails (Premature end of script headers)
by Anonymous Monk on Jul 20, 2016 at 06:36 UTC |