Access shell scripts from HTML page


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Access shell scripts from HTML page
# 1  
Old 08-09-2004
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 Smilie ) , then I'd much appreciate hearing them.



Many thanks,
Neil
# 2  
Old 08-09-2004
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 05:41 PM..
# 3  
Old 08-09-2004
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>

# 4  
Old 02-16-2005
*nevermind*

Last edited by douknownam; 02-16-2005 at 11:04 PM..
# 5  
Old 03-01-2005
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

How to Use a UNIX Shell Script to Create an HTML Web Page?

dear friends , in my work i have to monitor some system performance in hourly basis by runing some commands , for example (lpstat) to know that all the queue is ready how can i create webpage and connect it with the server (AIX operating system) and make this page refreshed every 10 second and... (12 Replies)
Discussion started by: rami abusweilei
12 Replies

2. Shell Programming and Scripting

Dynamic checkbox(HTML page) for each process using shell script

Hi friends, I m newbie to bash scripting , i m writing script(bash) that will display all processes which r running in my system in an html page, everything going fine but i m not able to get checkbox dynamically for each process in html page ,so that i can mark that process... (2 Replies)
Discussion started by: vagga06
2 Replies

3. Shell Programming and Scripting

Migrating from Shell Script to HTML Page

Hi, Need Help, Recently I have thought to migrating my Korn Shell Scripts to html page..., already webserv is running on my unix machine. How to migrate the shell scripts to html page.. Please refer any web portal or sample codes. Thanks in Adavce (2 Replies)
Discussion started by: l_gshankar24
2 Replies

4. Red Hat

Publishing HTML Page

Hi All, Thanks for reading. I am not sure if I am asking this in the correct group. But here it goes: There is a shell script which does some system checks and creates an html file called system_summary.html on my Red Hat machine say in /reports directory every hour. Now I want to view it... (6 Replies)
Discussion started by: deepakgang
6 Replies

5. Web Development

Call shell script from HTML page - without web server

Hi, I have html page in my unix machine(server), which I will open with firefox or mozilla available in unix machine. Firefox or mozilla will be opened using x windows. Since I have access to unix machien(like other users) and this HTML page is for user having access to Unix machine, I see no... (7 Replies)
Discussion started by: vamanu9
7 Replies

6. Shell Programming and Scripting

background image not loading in newly thrown html page by shell script

I m trying to throw back html page when a file is found.While throwing back html page, the background image is not coming. I am using Apache server.Please suggest how to resolve... #!/bin/ksh echo -e "Content-type: text/html\n\n" echo "<html><head></head><body background=\"/asc/ppp.jpg\">"... (10 Replies)
Discussion started by: ravi18s
10 Replies

7. Web Development

findstr in html page

I am planning to create an html page that will count number of connected ports, challenge for me is how to put it in a page. Thanks! (1 Reply)
Discussion started by: webmunkey23
1 Replies

8. Solaris

Accessing a HTML page

Hi All, In our unix server we have an apache web server running. I can access the default apache web page from my windows machine. Now, I want to create my own webpage. Therefore I created webpage at /export/home/myname/test.html file. Where do I need to place this file and what do I need... (0 Replies)
Discussion started by: pkm_oec
0 Replies

9. Shell Programming and Scripting

html withing shell scripts,how??

Hi can anybody guide me to write html programs using shell script. FYI: I use ksh. Thanks in advance, Divya (6 Replies)
Discussion started by: divzz
6 Replies

10. Shell Programming and Scripting

Invoking shell script from html/jsp page

I want to invoke shell script named bubesh.sh when submit button clicked on html/jsp page.I am using an apache server and the html & shell script are in the same working directory.Please help. (2 Replies)
Discussion started by: bubeshj
2 Replies
Login or Register to Ask a Question