executing a shell script from within a cgi script
executing a shell script from within a cgi script
(OP)
I would like to run a Shell Script from within one of My Perl Scripts. Say I wanted to run the shell script “go.sh” how would I execute it from within my Perl Script, or what would the syntax be to kick it off? Preferably from within the Korn Shell.
RE: executing a shell script from within a cgi script
there is a difference between them, i just don't remember what it is right now.
RE: executing a shell script from within a cgi script
RE: executing a shell script from within a cgi script
Any time you start a second process from inside a CGI, you must be deliberate how you spawn the second process and how you pass args to it. Anyone who can do a 'view source' on a HTML form can easily figure out how to pass extra args in with your inputs from the form.
keep the rudder amid ship and beware the odd typo
RE: executing a shell script from within a cgi script
RE: executing a shell script from within a cgi script
As far as security, if your script input includes shell metacharacters which preemptively complete the expected command, and the input further contains other commands, then the perpetrator has gained access to the system with the privileges of the CGI uid. For instance, the Perl code @ans = `grep '$user_field' some.file`; given predicted input to the $user_field variable would simply perform grep on it. Given the user input to $user_field of ; rm -fr / ; would delete everything from the owner’s home directory (http://www.perl.com/CPAN-local/doc/FAQs/cgi/perl-cgi-faq.html).
Don't check for things which may break your code... match your input to exactly what it should look like if valid using regular expressions. Don't let any potentially invalid input be passed to your script; only accept what you know to be valid.
Enabling taint mode (#!/usr/bin/perl -T) will warn you if you have any dangerous system calls using data which has not been checked.
Sincerely,
Tom Anderson
CEO, Order amid Chaos, Inc.
http://www.oac-design.com
RE: executing a shell script from within a cgi script