Results 1 to 6 of 6
Hi, this is more of yes or no question. But is it possible for me to have a web page with certain fields that when completed a bash script is ...
- 06-11-2007 #1Just Joined!
- Join Date
- Feb 2007
- Posts
- 76
Is it possible to do this?
Hi, this is more of yes or no question. But is it possible for me to have a web page with certain fields that when completed a bash script is created and executed with the information entered in the web page? For example: I make a web page containing a field of domain names. When a domain name is submitted, a bash script will be created and executed so that the domain name entered will be in my virtual hosts file. Is it possible for me to do something like that?
- 06-12-2007 #2
I don't see why not. You make a form, have that form pass the info to a PHP or CGI script, which writes the script for you. You then execute it. You would obviously need to have permission to modify whatever file you're changing, but this seems doable.
Having said that, you need to be VERY wary when taking user input and executing it. For instance, imagine if as the username, I enter:
If you take that and print it to a Bash script, you can very possibly cause damage (maybe not in this particular case because the web server user probably doesn't have a home, but you get the point).Code:alex; rm -R ~/;
DISTRO=Arch
Registered Linux User #388732
- 06-12-2007 #3Just Joined!
- Join Date
- Feb 2007
- Posts
- 76
Thanks for the reply.
So pretty much I can use PHP to write the bash script.
- 06-14-2007 #4
Why do you need both? Why do you need to write more than one script?
Write a bash script that takes the information from the form and processes it. The easiest way it to use SSI to invoke the script.
Read the article, Parsing Web Form Input in CGI Shell Scripts, for a bash function to parse form input.
- 06-18-2007 #5Just Joined!
- Join Date
- Feb 2007
- Posts
- 76
Thanks for the reply.
I've never used forms to take user input to create shell scripts, so I'm looking for the easiest way that something like this can be done.
- 06-19-2007 #6


Reply With Quote
