Access shell scripts from HTML page

Hi,

I need (have been asked/order/instructed) to migrate the access of a number of ksh scripts into a html/web page environment. Currently access is with the user logging onto a unix box and accessing the scripts that way. The users are not unix people so I have restricted the access solely to the scripts they require, but access should be stopped completely.

I have produced very simple web interfaces before that would link off to documents and procedures but nothing that would link off and execute a unix script.

Having searched this board and others I can't seem to find anything that will help point me in the correct direction. Can you access unix based scripts using simple html or does this require php or cgi (not really sure what these are or how the code may look)?

if there are any suggestions or thoughts (base on this thread :wink: ) , then I'd much appreciate hearing them.

Many thanks,
Neil

In order to achieve this, I'd say that you'll need to have a web server running. Apache will allow you to use shell scripts via CGI, so this may be the easiest choice.

You could also use Server Side Includes (see here) but again you'd need to have a webserver running and create the correct .htaccess file for the SSI to work.

You could have SSI such as

<!--#exec cmd="/path/to/my/script args" -->

within an HTML document that should do as you want.

Cheers
ZB

Here is an example of doing a trace route from a Solaris server via html. tracearoute is the html page first seen. Then tracearoute.cgi is the ksh script that is seen if you try it a second time and gives you the output.

Tracearoute.cgi - this should be placed in your cgi-bin directory

#!/bin/ksh 
#
#
echo "Content-type: text/html"
echo
#
fullstring="$QUERY_STRING"
tracer=`echo $fullstring|awk -F= '{print $2}'`
#
echo " <BODY>"
echo "<img src=\"/images/xlogo.gif\" width=100 border=0 
ALT=\"Logo\"><P>"
echo "  <H2>  Trace a Route </H2>" echo "<A HREF=\"/index.html\"> 
<IMG
SRC=\"/icons/back.gif\" ALT=\"Back\"></A><P>" echo "  <HR size=2 
noshade>"
echo "<pre>" if [ $QUERY_STRING = "msg=" ] ; then
	echo "Next time put in a system name or IP address"
else
	echo "`/u/sbin/traceroute $tracer`"
fi
echo "<pre>"
echo "<HR size=2 noshade>"
echo "<form action=\"/cgi-bin/tracearoute.cgi\">"
echo "<table border>"
echo "<p>"
echo "<tr>"
echo "	<th>Enter either a system name or IP address:<br>"
echo "	<input type=text name=\"msg\" maxlength=\"40\" size=40><br>"
echo "	</th>"
echo "</tr>"
echo "</table>"
echo "<p>"
echo "<input type=submit value=\"Trace It!\"><input type=reset><br>" 
echo
"</form>" echo "<HR size=2 noshade>" echo "<SCRIPT 
LANGUAGE=\"JavaScript\">"
echo "<!-- Begin" echo "var m = \"Updated: \" + document.lastModified;" 
echo
"var p = m.length;" echo "document.write(m.substring(p, 0));" echo "// 
End
-->" echo "</SCRIPT>" echo "" echo " </BODY>" echo "</NOFRAMES>" # exit

Code for html page - have a link for it on your index.html page

<HTML>
<HEAD>
 <TITLE> Trace a Route </TITLE>
</HEAD>
 <BODY>
<img src="/images/xlogo.gif" width=100 border=0 ALT="Logo"><P>
  <H2>  Trace a Route </H2>
<A HREF="/index.html"> <IMG SRC="/icons/back.gif" ALT="Back"></A><P>
  <HR size=2 noshade>
<form action="/cgi-bin/tracearoute.cgi">
<table border>
<p>
<tr>
	<th>Enter either a system name or IP address:<br>
	<input type=text name="msg" maxlength="40" size=40><br>
	</th>
</tr>
</table>
<p>
<input type=submit value="Trace It!"><input type=reset><br> </form> <HR
size=2 noshade> <SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var m = "Updated: " + document.lastModified;
var p = m.length;
document.write(m.substring(p, 0));
// End -->
</SCRIPT>

 </BODY>
</NOFRAMES>
</HTML>

*nevermind*

RTM,

How did you get the javascript working within your cgi script? I've attempted to incorporated a simple a timeout for the page via javascript and it doesn't seem to recognize it. Is there an order to where the javascript should be placed within the cgi script?