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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

system ("shellscript"); - question

Status
Not open for further replies.

subotai

Programmer
Jun 26, 2002
6
DE
Greetings!

Environment: linux, perl interpreter, browser.
I want to run a shell script from a perl script in my browser.
Dont i do this with 'system ("shellscript");' ?
Works with things like ("touch test.txt"), but it does not execute my shellscript.
Any ideas?

thank you in advance,
Subotai
 
If the script that you are trying to call is not in a directory that is defined in your $PATH environmental variable then the system() call won't be able to find the file. You will need to specify a relative or absolute path when you call the file.

ex.
system("./myscript.pl"); # if the file is in the same directory as the calling script.
or
system("/home/mrwizzard/perlscripts/myscript.pl");
# using absolute path

jaa
 
Hello Justice41!

I've taken into account your information, but it still wont exec. Tried the same with system ("touch /PATH/something"); and it worked.

I've set all the scripts rights to x, r and w, owner to root, and the webserver has root access rights. Cant really figure out what is wrong.

If you can think of anything else, i would greatly appreciate it!

thanks anyway, and greetings,
Subotai
 
I hope that machine is not on a network.
You're really inviting disaster.
You should never give a web server root permissions.

Might be something internal to the shell script.
The shell script will be running as the web_server daemon. If there is anything for which the shell script lacks sufficient path info or permissions, the shell script will fail.

Can you post a little concise code? 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Try executing the code from the tick with backticks instead.

`shellscript.sh`

also, just for debugging, change the premissions of 'other' to rx.

chmod o+rx shellscript.sh

And, I know this is basic but I have to ask, the script works when you run it from the command line, yes?

jaa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top