Hello,
I have a CGI script which displays a form. When form is submitted it runs a command on the server which outputs a complete html document including <HTML>,<HEAD>, <BODY> tags.
After the command runs and the HTML document is created I want my cgi script to take the output and display it a new browser window.
Is this possible using CGI.pm? Any tips or sample code is appreciated.
My original concept was to take the newly created html document and display it below my form..but since I am already within a 'q->start_html' section....then it would conflict with a new set of <HTML> tags embedded in the document.
Here is my Code:
I have a CGI script which displays a form. When form is submitted it runs a command on the server which outputs a complete html document including <HTML>,<HEAD>, <BODY> tags.
After the command runs and the HTML document is created I want my cgi script to take the output and display it a new browser window.
Is this possible using CGI.pm? Any tips or sample code is appreciated.
My original concept was to take the newly created html document and display it below my form..but since I am already within a 'q->start_html' section....then it would conflict with a new set of <HTML> tags embedded in the document.
Here is my Code:
Code:
use CGI;
my $q = new CGI;
my $url = $q->url();
my @names = $q->param;
my $which_one = 'none';
my $len = @names;
my $syscode = 'none';
my $tbl = 'none';
print $q->header(-type=>'text/html'),
$q->start_html(-title=>'Lawson Applications DB Doc Web Client'),
$q->start_form(-method=>'POST',-action=>'mytest_b.exe'),
$q->start_table({-border=>1,-align=>CENTER,-bordercolor=>'0099CC',-bgcolor=>'FFFFFF'}),
$q->Tr({-align=>LEFT,-valign=>TOP}),
$q->start_td, $q->h3("System Code:"),$q->end_td,
$q->start_td, $q->textfield(-name=>'syscode',-size=>'3',-maxlength=>'2'),$q->end_td,
$q->Tr({-align=>CENTER,-valign=>TOP}),
$q->start_td, $q->h3("Table Name:"),$q->end_td,
$q->start_td, $q->textfield(-name=>'tblname',-size=>'11',-maxlength=>'10'),$q->end_td,
$q->Tr({-align=>CENTER,-valign=>TOP}),
$q->start_td, $q->submit({-name=>'btnReset',-label=>'Reset'}),$q->end_td,
$q->start_td, $q->submit({-name=>'btnSubmit',-label=>'Submit'}),$q->end_td,
$q->end_table(),
$q->end_form();
$which_one = $q->param('btnSubmit');
if ($which_one eq 'Submit')
{
$syscode = $q->param('syscode');
$tbl = $q->param('tblname');
@url = split(/\//,$q->url(-absolute=>1));
$pl = $url[2];
$command = 'dbdoc ' . "$pl $syscode $tbl";
$out = `$command 2>/dev/null`;
print $q->h5($out); ##I want the new html output to be displayed in a new browser window
print $q->h5($command);
}
else
{
$q->delete_all();
}
print $q->end_html;
exit (0);