wirechild
07-25-2004, 04:39 AM
I have a form that takes a couple IP address's and post them to a CGI script. One of the IP's is the router to Telnet to and the other is the host to ping form that router. This part works correclty however the output of the ping is not displayed in the browser. Can someone please help me? Here is contents of all the files and the final page. I can verify on the router that the telnet and ping is working correctly using debug commands I can see what is happening.
HTML Form:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<form method="post" action="/cgi-bin/form.cgi">
<h2>This is a test!</h2>
<br>
Enter Router to Ping from:
<input type="text" name="ip">
<BR>
Enter Address to Ping:
<input type="text" name="ping">
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
CGI Script named form.cgi
#!c:\Perl\bin\perl.exe -w
use CGI;
use Net::Telnet;
$form = new CGI;
#$command = $form->param('command');
#$router = $form->param('router');
$ping = $form->param('ping');
$ip = $form->param('ip');
$t = new Net::Telnet->new(Host=>$ip, Port=>23, Errmode=>'return');
$t->waitfor('termserv>');
@return = $t->cmd("ping $ping");
#$t->waitfor(String => 'termserv>');
$t->close();
print $form->header();
print $form->start_html(
-title=>'LG',
-BGCOLOR=>'white');
print "You asked me to telnet to <strong>$ip</strong> and Ping <strong>$ping</strong>\n";
print "<PRE>\n";
print "@return<BR>\n";
print "</PRE>\n";
print "<br><br>\n";
#print $t->cmd($_);
print "Thanks\n";
print $form->end_html();
Output webpage(What actually gets printed):
You asked me to telnet to 192.168.0.101 and Ping 192.168.0.1
Thanks
As you can see I am looking for @return to be printed to the page and it is not.
HTML Form:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<form method="post" action="/cgi-bin/form.cgi">
<h2>This is a test!</h2>
<br>
Enter Router to Ping from:
<input type="text" name="ip">
<BR>
Enter Address to Ping:
<input type="text" name="ping">
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
CGI Script named form.cgi
#!c:\Perl\bin\perl.exe -w
use CGI;
use Net::Telnet;
$form = new CGI;
#$command = $form->param('command');
#$router = $form->param('router');
$ping = $form->param('ping');
$ip = $form->param('ip');
$t = new Net::Telnet->new(Host=>$ip, Port=>23, Errmode=>'return');
$t->waitfor('termserv>');
@return = $t->cmd("ping $ping");
#$t->waitfor(String => 'termserv>');
$t->close();
print $form->header();
print $form->start_html(
-title=>'LG',
-BGCOLOR=>'white');
print "You asked me to telnet to <strong>$ip</strong> and Ping <strong>$ping</strong>\n";
print "<PRE>\n";
print "@return<BR>\n";
print "</PRE>\n";
print "<br><br>\n";
#print $t->cmd($_);
print "Thanks\n";
print $form->end_html();
Output webpage(What actually gets printed):
You asked me to telnet to 192.168.0.101 and Ping 192.168.0.1
Thanks
As you can see I am looking for @return to be printed to the page and it is not.