Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to dynamically set the form action using jQuery.

760 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

19 Experts available now in Live!

Get 1:1 Help Now