Solved

is it possible to use a CGI script to create other CGI scripts?

Posted on 2000-03-21
5
188 Views
Last Modified: 2011-04-14
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!
0
Comment
Question by:flahertd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 16

Expert Comment

by:maneshr
ID: 2642053
"What can I do to prevent the current CGI script from interpreting the cgi code I want to write to the new script? "

you dont have to do anything. As long as your CGI code is within " and you have escaped any special chars you are safe.

0
 
LVL 5

Expert Comment

by:PC_User321
ID: 2642367
$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;



0
 
LVL 16

Expert Comment

by:maneshr
ID: 2645121
flahertd,

were you able to find a solution to your problem? if so, pl. let this forum know of the solution.

thanks
0
 

Author Comment

by:flahertd
ID: 2645525
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/local/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_interpreted\";";
           
So then in NEW_CGI_SCRIPT I would end up with:
#!/usr/local/bin/perl
$ENV{"PATH"} .= ":/usr/local/bin:/usr/local/lib/perl";
require "/path/to/cgi-bin/cgi.pl";
$filename = "/path/to/file";

0
 
LVL 16

Accepted Solution

by:
maneshr earned 100 total points
ID: 2645672
glad to know that your problem was solved. :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Filtering a file to table 9 102
work on ods spreadsheet with perl in ubuntu 4 81
Problem with one substitution modifying another 3 77
Writing a parser for java language 4 91
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question