Solved

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

Posted on 2007-11-21
2
228 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

827 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