Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System Command problem in CGI

Status
Not open for further replies.

vrajasek

Programmer
Jan 14, 2004
7
US
Hi Folks.

I have a strange yet deep concept related problem. I have Apache installed on my local machine. I could run all the cgi scripts except for one. This CGI script of mine is working properly except for one thing. The system command in it which calls another perl program of mine is being overlooked, hahaa, i.e. My perl program if run from command line is working perfecly, but if I use system command to run the perl program from the CGI program, its not running.

I started reading some material on it and saw that it (System command in CGI) leads to major security concern, but since I will be using it inside the intranet with firewall security, I am thinking of taking my chances. But I couldnot find any solution of how to make the System command work.

Any suggestions are greatly appreciated.

Thanks,
Vijay.
 
Vijay,

there could be a syntax error in your sytem("*") call, or you're not specifying the path to the perl executable properly, or Apache is incorrectly configured to run the CGI script from the direcory specified are three possible causes of your problem.

If you post the code for the system call, and spec the functions of the arguments, we may be able to help you further

HTH
--Paul



It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
vrajasek,

You must remember that you have to give your script the correct permissions so that it is able to see the other folders on your drive, otherwise it will only be able to see files inside its own folder (e.g. /home/httpd/cgi-bin/).

If you haven't set permissions it means you would have to put your perl script in this folder. If this is the case already perhaps there is a syntax error. My code looks something like this:

system("/perlscript.pl");

Try writing a simple perl script that simply outputs a statement like "Hello world!". Then test this script through your cgi-script.

Get back to me with the results, there are a few other possibilitys that could be responsible for your problem.
 
You can also try using backticks which return the output of the external command

so

$output = `/your/perl/script.pl`;

You can then print out $output to see exactly what went wrong. I bet its a permissions issues as well.

Backtick is similiar to the system() command.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top