The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
html withing shell scripts,how?? divzz Shell Programming and Scripting 6 05-28-2008 05:11 AM
Html web page to Unix Connectivity abhilashnair UNIX and Linux Applications 1 03-06-2008 06:13 AM
Invoking shell script from html/jsp page bubeshj Shell Programming and Scripting 2 06-28-2006 10:53 AM
linking unix generated text file to html page alexd Shell Programming and Scripting 1 11-13-2002 08:21 AM
Unix Manual (man-page) pages in HTML killerserv News, Links, Events and Announcements 1 06-25-2002 09:05 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-09-2004
Registered User
 

Join Date: Aug 2002
Location: London, England
Posts: 84
Question 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 ) , then I'd much appreciate hearing them.



Many thanks,
Neil
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-09-2004
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
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
Code:
<!--#exec cmd="/path/to/my/script args" -->
within an HTML document that should do as you want.

Cheers
ZB

Last edited by zazzybob; 08-09-2004 at 01:41 PM.
Reply With Quote
  #3 (permalink)  
Old 08-09-2004
RTM's Avatar
RTM RTM is offline
Hog Hunter
 
Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
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
Code:
#!/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
Code:
<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>
Reply With Quote
  #4 (permalink)  
Old 02-16-2005
Member
 

Join Date: May 2004
Posts: 35
*nevermind*

Last edited by douknownam; 02-16-2005 at 07:04 PM.
Reply With Quote
  #5 (permalink)  
Old 03-01-2005
man man is offline
Registered User
 

Join Date: Feb 2005
Posts: 10
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?
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0