I have taken care of ssh authenitcation. When I run my shell script from command line the output is:
[User@Hostname ~]$ ./ping.sh
PING target 56(84) bytes of data.
64 bytes from target: icmp_seq=0 ttl=64 time=0.339 ms
64 bytes from target: icmp_seq=1 ttl=64 time=0.388 ms
64 bytes from target: icmp_seq=2 ttl=64 time=0.342 ms
Killed by signal 2.
[User@Hostname ~]$
I am trying to achieve the same thing in webinterface. I am not getting the output in the webpage. The compiler has no complain. Here goes the complete code.
#!/usr/bin/perl
#domain name suffix - if we need it
$domainName="";
# Get the input
$buffer = $ENV{'QUERY_STRING'};
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
print "Content-type: text/html\n\n";
print <<__HTML__;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Rockmountain®/Webinterface™</TITLE>
<STYLE type="text/css">
h1.headerTool
{
font-size: 30pt;
font-style: italic;
font-weight: bold;
letter-spacing: -4px;
}
.headerReg, .headerTM
{
font-size: 12pt;
vertical-align: super;
}
.headerWebinterface
{
font-size: 28;
font-weight: 500;
letter-spacing: 0px;
}
body
{
background-color: #000033;
color: #ffffff;
font-family: Arial, Verdana, sans-serif;
}
.systemMsg
{
font-size: 14pt;
font-weight: bold;
}
</STYLE>
</HEAD>
<BODY>
<h1 class="headerTool">NETCOOL<span class="headerReg">®</span>/ <s
+pan class="headerWebinterface">Webinterface</span><span class="header
+TM">™</span></h1>
<CENTER>
<HR HEIGHT="15" >
</CENTER>
__HTML__
$nodeName = "seres";
if (! $FORM{"\$selected_rows.Node"}) {
print "<p class=\"systemMsg\">No Node Specified.</p></body></h
+tml>";
die;
}
else {
$nodeName = $FORM{"\$selected_rows.Node"}.$domainName;
print "<p class=\"systemMsg\">Pinging host ".$nodeName."</p>\n
+";
}
$USER = "User";
$HOST="hostname";
$CMD="/usr/sbin/ping";
#open(PING,"/usr/sbin/ping -s ".$nodeName." 64 10 |");
open(PING,"ssh ".$USER."@".$HOST." /bin/ping -s ".$nodeName." 64 10
+|");
$old_fh = select(STDOUT);
$| = 1;
select($old_fh);
print "<PRE>";
while(<PING>) {
print;
}
print "</PRE>";
print "<CENTER><HR HEIGHT=\"15\" ></CENTER>";
print <<__HTML__;
<form action="">
<div align="center"><input type="button" value="Close Window" onClick=
+"javascript:window.close();"></div>
</form>
</BODY>
</HTML>
__HTML__
|