Analyzing a simple UNIX shell script.

   

Enter two strings. We'll see if we can find an English word which contains both as substrings:

 

The HTML form: <form>
<p><input name="a" size="12">
<input name="b" size="12">
<input onclick="ship(a.value,b.value)"
type="button" value="send"></p>
</form>
The values in
fields a and b
are passed as
parameters to
the function "ship"
The JavaScript function:
Activated when the user
clicks on the "send" button.
<script>
function ship(v,w){
u="http://granite.sru.edu/~ddailey/cgi/eleven?"+v+"+"+w
window.location=u;
}
</script>
The window's location
is redirected to an
address on granite
consisting of the URL
of a file
(ddailey/public_html/
cgi/eleven)
followed by the string ?v+w
where v and w are the
user-provided strings
passed as variables into
a UNIX script.
The UNIX script, located on granite in the file
ddailey/public_html/
cgi/eleven
#! /bin/sh
echo "Content-type: text/html"
echo
echo
echo "<html><head>"
echo "</head><body>"
echo $1" and "$2" are both found in:<br>"
grep $1 /homes/ddailey/public_html/words|grep $2|head -1
echo "</body></html>"
This executable script
uses "echo" to type html
as output (directed by the server back to the
client). It also finds all
strings in the file "words"
that contain the first
user-given string then, from those, finds those
that also have the second
string. Only the first one
is returned.
The HTML source returned to the browser <html><head>
</head><body>
go and do are both found in:<br>
gondola
<br></body></html>