for yan...............
===========================================================
#!/bin/sh
#
# A simple web server
#
exec 2>/dev/null
PATH="/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export PATH
unset TERM
REQ=""
HOST=""
DATE="`date -uR`"
read -r line
case "$line" in
GET\ *\ *)
REQ=`echo $line | cut -d' ' -f2`
;;
esac
while read -r line ; do
line=`echo "$line" | sed -e 's/.$//'`
if [ "$line" = "" ]; then break; fi
case "$line" in
Host:\ *)
HOST=`echo $line | cut -d' ' -f2`
;;
esac
done
case "$REQ" in
\/hello)
#
# example fixed page....
#
echo -e "HTTP/1.0 200 OK\r"
echo -e "Server: MickyMouse0.1\r"
echo -e "Date: $DATE\r"
echo -e "Connection: close\r"
echo -e "Content-Type: text/html; charset="ASCII"\r"
echo -e "\r"
echo -e "<html><head>\r"
echo -e "<title>greeting</title>\r"
echo -e "</head>\r"
echo -e "<body>\r"
echo -e "<h1>Hello!</h1>\r"
echo -e "</body></html>\r"
;;
\/usage)
#
# example execution of commands
#
echo -e "HTTP/1.0 200 OK\r"
echo -e "Server: MickyMouse0.1\r"
echo -e "Date: $DATE\r"
echo -e "Connection: close\r"
#
# refresh every 5 secs. comment this out for a once only page....
echo -e "Refresh: 5\r"
echo -e "Content-Type: text/plain; charset="ASCII"\r"
echo -e "\r"
echo -e "\r"
echo -e "$DATE\r\n\r"
echo -e "Uptime......\r\n\r"
uptime
echo -e "\r\nMemory Usage......\r\n\r"
free
echo -e "\r\nDisk Usage......\r\n\r"
df
;;
\/jj*)
#
# example redirection......
#
REQ=`echo "$REQ" | sed -e "s/^\/jj//"`
echo -e "HTTP/1.0 301 ok\r"
echo -e "Location: http://www.comp.leeds.ac.uk/jj${REQ}\r"
;;
*)
#
# page not found
#
echo -e "HTTP/1.0 404 Not Found.\r"
echo -e "Server: MickyMouse0.1\r"
echo -e "Date: $DATE\r"
echo -e "Connection: close\r"
echo -e "Content-Type: text/html; charset="ASCII"\r"
echo -e "\r"
echo -e "<html><head>\r"
echo -e "<title>Not Found</title>\r"
echo -e "<h2><b><em>$REQ</em></b></h2>\r"
echo -e "<h2>Page Not Found.</h2>\r"
echo -e "</body></html>\r"
;;
esac
echo -e "\r"
exit
====================================================================
---------- Forwarded message ----------
Date: Wed, 18 Jan 2006 11:18:00 +0000 (GMT)
From: Jim Jackson <>
To:
Subject: Re: [ts-7000] Re: how to request 7250 execute command from
external web browser?
On Wed, 18 Jan 2006, chentom60 wrote:
> Also, I heard python is more simpler and more powerful than Perl. Is
> it true?
Apples and Oranges -which is the best fruit?
I'd argue that for general scripting purposes then Perl is the most
powerful scripting language there is, but if you are designing a large
user application then maybe it isn't appropriate.
> I would appreciate if anyone would give me some explaination.
Try googling - there is tons of stuff out there.
For many simple purposes your best scripting language is just sh.
As an example I've attached a simple shell script that acts as
a web browser. I call it webserv.sh
Install the shell script in a directory - say /usr/bin
make sure it is executable
chmod 755 /usr/bin/webserv.sh
edit /etc/inetd.conf and add a line like.....
webcache stream tcp nowait root /usr/bin/webserv.sh webserv.sh
then find the process number of your inetd process
ps | grep inetd
333 root 596 S /usr/sbin/inetd
4560 arm 428 S grep inetd
Then send the inetd process a HUP signal make it reread the config file
kill -HUP 333
Then you should have a "webserver" listening on the webcache port (8080)
assuming your ts7200 has the address 192.168.0.50, point a web browser
at
http://192.168.0.50:8080/hello
a simple fixed hello page
http://192.168.0.50:8080/usage
an example of executing commands and use of refresh
http://192.168.0.50:8080/fred
example of a 404 simple page for a non existant page
http://192.168.0.50:8080/jj
an example of a redirect - if you browser has internet access, you'll
end up at my webpage :-)
The script is only 100 odd lines and is very easy to follow and to
customise for your own usage.
Who needs apache :-)
Jim
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|