Running shell scripts from web browser

I am in need of a mechanism to run shell scripts from web browser. Could any one of you guide me as to which technology to choose? I have some scripts which take some arguments. Appreciate you response.

The Apache can handle this task.

Jackie,

Can you give me some more details as to how to integrate?

You can make a form and just like any other cgi script, put the script in your web server's cgi bin and point the form to it.
Something like:

<FORM METHOD=POST ACTION="http://mywebserver.com/cgi-bin/myscript.cgi">
<P><FONT COLOR="#ddd20f" FACE="Trebuchet MS"><B>Enter data to pass to script below </B></FONT><BR>
<INPUT NAME="NAME" TYPE="text" SIZE="25" VALUE="enter your data here"><BR>
</FONT</P>
<P>
<center><INPUT TYPE=submit VALUE="Send">
</center>
</p>
</FORM>

This is actually part of a working form that I use at work, just changed the names of the webserver and the script. While the script ends in .cgi, myscript.cgi is actually a korn shell script. This form passes the variable NAME to the script

Hi All,
Daily I used to do some daily check on UNIX server.

I want this task to be done thru a browser.

For example:
if i open a browser i must get a screen like below...... style which must have options as follows:

                                 UNIX Daily Check Page

commands:
bdf
ps -ef grep $someprocess
top

if user clicks the button he should get the result of the command and it must be stored in temorary buffer and final.................

a report button must be there by clicking he must be able to generate the whole output result into a single xls file..... and this has to be sent to some mailbox....................

can this be done using simple html code????

please advice................

Vangalli

Shock,
We have ksh scripts here and we get csv files as an out put. Is there a way to display all the csv files? Is there any tutorial (on CGI) on how to set this up? Appreciate your response.

I'm sure you can find plenty of tutorials on cgi on the web, although I don't know about tutorials using shell scripts; most use perl, asp, etc... anyway, continuing with the example above, forgot to mention that the form passes the variable NAME to myscript.cgi as a string, not as a variable. It's an important difference because myscript.cgi needs to read the string and make it a variable.

Let me tell you what myscript.cgi does, so you'll get a better idea, and can use it as a base for what you want to do. A user goes to the web page, and enters an ID. This ID is going to be appended to an access file to allow the user WAP access to several web applications.
myscript.cgi looks something like this:


#!/usr/bin/ksh
echo "content-type: text/plain"
echo
read USERID?   ## this reads the NAME variable passed by the web form
echo ${USERID} > /opt/apache/htdocs/application/temp/userID
NEWID=$(sed 's/NAME=//' /opt/apache/htdocs/application/temp/userID) ## this cleans the string that was passed by the form
echo ${NEWID} by ADMIN  >> /opt/apache/htdocs/application/access.dat.req  ## access.dat.req is read by a cronjob every night

## This part will actually generate a web page that will inform the user that  his/her ID was submitted

echo "<html> <body BGCOLOR="#000000" TEXT="#ddd20f">"
echo "<FONT FACE="Trebuchet MS">"
echo "<center><p><big>userID ${NEWID} has been recorded</big><br>"
echo "</p>"
echo "userIDs submitted before 7:00PM ET are<BR>"
echo " activated the same day after 9:00PM ET<BR>"
echo "<BR>"
echo "For any issues with this tool, please open <BR>"
echo " a ticket in the application queue<BR>"
echo "</FONT>"
echo "</center></body></html>"

I don't know how big your csv files are, or how you want to display them, or what data is input by the web user. However, these snippets show you how to get data from the web form, how to run commands based on that data, and how to display the processed data immediately on your web browser after the data has been processed. At its most basic, you could make a variable like myCSV=$(cat file.csv), then

echo opening html tags,
echo ${myCSV}
echo closing html tags

and that should display your csv on the web.

Oh, and before I forget, you may have to tweak the script depending what browser you use. I did this one for corporate, so it works with IE, and the mozilla browser that come with Solaris 10 (which I use ). I didn't test it for any other browsers.

Shock,

My requirement is that the user should be able to run java program from the GUI and program has 8 arguments. The arguments are alpha numeric......mostly coma separated. I will start with your code snippet...