Nov 25 2006, 02:40 PM
Post
#1
|
|
![]() Group: Admin Posts: 3,281 Joined: 29-July 04 From: Cambridge, England Member No.: 4,149 |
Is anyone interested in my crude hackery which allows you to serve web pages on your zaurus without installing any software? I'll assume so!
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 # 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 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!
Attached File(s)
|
|
|
|
speculatrix Crude Httpd On Zaurus Nov 25 2006, 02:40 PM
matthis Wow! Thank you this is really interesting... Nov 26 2006, 04:45 AM
speculatrix I can now reveal two things... an enhanced version... Nov 27 2006, 03:22 PM
speculatrix p.s. of course this also means it would be possibl... Nov 27 2006, 03:36 PM
speculatrix Apache is 100's of KB, and yet I claimed to wr... Nov 30 2006, 09:35 AM
Da_Blitz wasent there a full webserver written in AWK on th... Dec 1 2006, 10:17 PM
speculatrix QUOTE(Da_Blitz @ Dec 2 2006, 07:17 AM)wasent ... Dec 3 2006, 03:28 PM
Da_Blitz ahh, yes i see. not the way i would have done it h... Dec 3 2006, 07:09 PM
nilch so now that we have this HTTP server working, how ... Dec 4 2006, 07:17 AM
koen QUOTE(nilch @ Dec 4 2006, 03:17 PM)so now tha... Dec 4 2006, 07:25 AM
speculatrix if you want a real webserver, try boa, the success... Dec 4 2006, 07:39 AM
Da_Blitz ive never really had a problem with thttpd unless ... Dec 4 2006, 09:51 PM
speculatrix have you looked at the Getting Things Done TiddlyW... Dec 5 2006, 04:43 AM
koen or just use http://www.angstrom-distribution.org/r... Dec 5 2006, 05:14 AM![]() ![]() |
|
Lo-Fi Version | Time is now: 19th June 2013 - 01:51 PM |