Sponsored Content
Top Forums Shell Programming and Scripting Access shell scripts from HTML page Post 54301 by RTM on Monday 9th of August 2004 04:43:11 PM
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>

 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.10 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 07:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy