exec cmd problem

in my html file,
i use SSI:
<!--#exec cmd="/home/sites/site69/web/cgi-bin/readbook.new.pl?id=stanley"-->

however, I can't get this pair of $ENV{'QUERY'},

my readbook.new.pl:


use CGI;
print "Content-type: text/html\n\n";

print $qs,"\n";
($num, $value) = split(/=/, $qs);
print $value,"\n";

$| = 1; # flush stdout on each write

print "<div align=center><TABLE width=75% BORDER=0 CELLPADDING=4>\n";
open(DATA, "<$datafile");

what is wrong?
what should i make it?

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

finikConnect With a Mentor Commented:
First of all, use <!--#include virtual
instead of exec cgi. It does work on cgi's, and doesn't make problems like
exec cgi does.

I use similar scheme to what you are describing, and it works well.
The code below passed parameters given to html file further to the included cgi:
In html I have:
<!--#include virtual="/cgi-bin/mp3list.cgi?${QUERY_STRING}"-->

and in cgi I do the usual:

use CGI;
$query = new CGI;
$search = $query->param('search');
$disk = $query->param('disk');
and so on. This is the right way to get parameters to a CGI. and not reinventing the wheel, like you did with parsing it by yourself.
Hope that helps. Good luck.
By the way, what is the point of "use CGI;" if you do all the things manually?
CGI.pm has a lot of nifty features that will make your life a lot easier:
mwhuenAuthor Commented:
Thank you, it works! :)
i add use CGI; because i want to debug it in shell.
I read the CGI.pm before, and are not so familiar with it,

I would like to ask more questions here,
it works when the file is .cgi, do u think it works with .pl too? (the file content is the same)
and one question more,
if i want to use CGI,
how can i get $name=stanley?

$query = new CGI;



1. About .cgi .pl...
It depends on web server config.
If it knows that .pl extension is .pl,
then "yes", you can rename it to .pl.
If you use apache, look for the next lines in the srm.conf or httpd.conf:

# To use CGI scripts:
AddHandler cgi-script .cgi .pl

2. The example you provided assumes
that the name of the control in the html form was "id", right? Then it will work.

All Courses

From novice to tech pro — start learning today.