Solved

How do I get input from a form to run a linux shell script?

Posted on 2007-11-21
2
223 Views
Last Modified: 2013-12-25
I have a script on a linux box that runs as this "script.sh argument1 argument2" How would I be able to define the arguments by a simple HTML form so that someone could run the report that this generates?
0
Comment
Question by:guitchicken
2 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 20331067
Create a form, eg:

<form action="/cgi-bin/script.pl" method="POST">
<i<input type="text" name="arg1" size="20">
<input type="text" name="arg2" size="20">
</form>

Then script.pl looks like:

#!/usr/bin/perl
use CGI;
my $q = new CGI;
my $arg1 = $q->param('arg1');
my $arg2 = $q->param('arg2');
print $q->header('text/plain');
system "/path/to/script.sh", $arg1, $arg2;

Note that you should make sure you sanitise any data from the form before calling the script.
0
 
LVL 3

Author Comment

by:guitchicken
ID: 20333125
Thanks, that worked great! I had the script already made but was asked for a web form to run it last minute and this definately saved me time trying to find out what needed to be done.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now