Find the answer to your Linux question:
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 ...
  1. #1
    Just 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?

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    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:
    Code:
    alex; rm -R ~/;
    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).
    DISTRO=Arch
    Registered Linux User #388732

  3. #3
    Just Joined!
    Join Date
    Feb 2007
    Posts
    76
    Thanks for the reply.
    So pretty much I can use PHP to write the bash script.

  4. #4
    Just Joined! cfajohnson's Avatar
    Join Date
    May 2007
    Location
    Toronto, Canada
    Posts
    52
    Quote Originally Posted by bigb89 View Post
    Thanks for the reply.
    So pretty much I can use PHP to write the bash script.

    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.

  5. #5
    Just 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.

  6. #6
    Just Joined! cfajohnson's Avatar
    Join Date
    May 2007
    Location
    Toronto, Canada
    Posts
    52
    Quote Originally Posted by bigb89 View Post
    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.
    Why do you need to create a shell script? Write one, and only one, that gets parameters from the form.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...