flahertd
asked on
is it possible to use a CGI script to create other CGI scripts?
I want to create a CGI script from within a CGI script. How do I get around the following:
open(NEW_CGI_SCRIPT, ">$address");
print NEW_CGI_SCRIPT "cgi code";
close(NEW_CGI_SCRIPT);
What can I do to prevent the current CGI script from interpreting the cgi code I want to write to the new script?
Any pointers would be appreciated!
open(NEW_CGI_SCRIPT, ">$address");
print NEW_CGI_SCRIPT "cgi code";
close(NEW_CGI_SCRIPT);
What can I do to prevent the current CGI script from interpreting the cgi code I want to write to the new script?
Any pointers would be appreciated!
$cgi_code = 'Your CGI code goes here;
$ signs get ignored because of the single quotes
Double quotes ignored "too".
End of CGI script';
print NEW_CGI_SCRIPT $cgi_code;
$ signs get ignored because of the single quotes
Double quotes ignored "too".
End of CGI script';
print NEW_CGI_SCRIPT $cgi_code;
flahertd,
were you able to find a solution to your problem? if so, pl. let this forum know of the solution.
thanks
were you able to find a solution to your problem? if so, pl. let this forum know of the solution.
thanks
ASKER
First, thanks for the suggestions!
What I did was a mixture of both -
I put some of the code within single
quotes, so that no special characters would be interpreted:
$cgi_code = '#!/usr/local/bin/perl
$ENV{"PATH"} .=
":/usr/local/bin:/usr/loca l/lib/perl ";
require "/path/to/cgi-bin/cgi.pl"; ';
print NEW_CGI_SCRIPT $cgi_code;
Then more code that I needed interpreted, I put in double quotes, backslashing the stuff I didn't want interpreted - it looks pretty ugly, but it does the job:
print NEW_CGI_SCRIPT "\$filename = \"$filepath_I_need_interpr eted\";";
So then in NEW_CGI_SCRIPT I would end up with:
#!/usr/local/bin/perl
$ENV{"PATH"} .= ":/usr/local/bin:/usr/loca l/lib/perl ";
require "/path/to/cgi-bin/cgi.pl";
$filename = "/path/to/file";
What I did was a mixture of both -
I put some of the code within single
quotes, so that no special characters would be interpreted:
$cgi_code = '#!/usr/local/bin/perl
$ENV{"PATH"} .=
":/usr/local/bin:/usr/loca
require "/path/to/cgi-bin/cgi.pl";
print NEW_CGI_SCRIPT $cgi_code;
Then more code that I needed interpreted, I put in double quotes, backslashing the stuff I didn't want interpreted - it looks pretty ugly, but it does the job:
print NEW_CGI_SCRIPT "\$filename = \"$filepath_I_need_interpr
So then in NEW_CGI_SCRIPT I would end up with:
#!/usr/local/bin/perl
$ENV{"PATH"} .= ":/usr/local/bin:/usr/loca
require "/path/to/cgi-bin/cgi.pl";
$filename = "/path/to/file";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you dont have to do anything. As long as your CGI code is within " and you have escaped any special chars you are safe.