At the end of the day, a web server can be written in a shell script, with the networking provided by inetd, so provided you generate the right http response headers it's actually quite trivial!
I've used this for quite a few years and not come across anyone else doing it, and it seems to me that the Z is an ideal target for something so light weight.
Add the following line to the bottom of your /etc/inetd.conf file:
CODE
http stream tcp nowait root /usr/sbin/tcpd /usr/local/bin/sh-httpd
don't worry about the spacing. Then you need to HUP inetd process, by entering the command "ps -ef | grep inet", look for the first number and enter "kill -1 xxxx". Or, in desperation, reboot! e.g.
CODE
# ps -ef | grep inet
root 4802 1 0 21:41 ? 00:00:00 /usr/sbin/inetd
root 5726 5671 0 22:41 pts/0 00:00:00 grep inet
# kill -1 4802
#
root 4802 1 0 21:41 ? 00:00:00 /usr/sbin/inetd
root 5726 5671 0 22:41 pts/0 00:00:00 grep inet
# kill -1 4802
#
Then create the following script, as /usr/local/bin/sh-httpd:
CODE
#!/bin/bash
DBGFILE=/tmp/sh-httpd.log
date >> $DBGFILE
H="IGNORE"
while [ "$H" != "" ];
do
echo $H >> $DBGFILE
read H
H=`echo $H | sed -e 's/^M//g'`
done
echo 'HTTP/1.1 200 OK'
echo -n "Date: "'
date|sed 's/ /, /''
echo 'Server: sh-http/0.01 (Linux/bash)'
echo 'Accept-Ranges: bytes'
echo 'Connection: close'
echo 'Content-Type: text/html'
echo ''
echo '<?xml version="1.0" encoding="ISO-8859-1"?>'
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
echo '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">'
echo '<head><title>Zaurus sh-httpd daemon</title></head>'
echo '<body bgcolor="#ffffff">'
echo "<p>"
echo "<b>hello</b>"
echo "</p>"
echo "</html>"
echo "finished" >> $DBGFILE
# end sh-httpd
DBGFILE=/tmp/sh-httpd.log
date >> $DBGFILE
H="IGNORE"
while [ "$H" != "" ];
do
echo $H >> $DBGFILE
read H
H=`echo $H | sed -e 's/^M//g'`
done
echo 'HTTP/1.1 200 OK'
echo -n "Date: "'
date|sed 's/ /, /''
echo 'Server: sh-http/0.01 (Linux/bash)'
echo 'Accept-Ranges: bytes'
echo 'Connection: close'
echo 'Content-Type: text/html'
echo ''
echo '<?xml version="1.0" encoding="ISO-8859-1"?>'
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
echo '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">'
echo '<head><title>Zaurus sh-httpd daemon</title></head>'
echo '<body bgcolor="#ffffff">'
echo "<p>"
echo "<b>hello</b>"
echo "</p>"
echo "</html>"
echo "finished" >> $DBGFILE
# end sh-httpd
A key part in the script is that you see ^M in the while loop, but it's actually a ctrl-m, which you get in vi by typing ctrl-v ctrl-m.
Or, attached is the script; I had to add a .txt type to make it uploadable.
Once created, make it executable using
CODE
chmod ugo+x /usr/local/bin/sh-httpd
Then test it, either from the local browser using "http://127.0.0.1" or remotely when usb networking is up (http://192.168.129.201) or over wifi. Note that if you've use iptables firewalling on your Z you need to punch a hole for port 80, e.g. "iptables -I INPUT -p tcp --dport 80 -j ACCEPT".
BTW, I am doing this now because I want to write a somewhat more sophisticated version in order to produce some local management tools for the Z which aren't present in the normal ROM, and also for a small secret project which will be revealed soon
--
edited quite a few times to ensure layout and clarity is up to standard!
