Warning: this is a htmlized version!
The original is across this link. |
####### # # E-scripts on http servers, clients, cgis, etc. # # Note 1: use the eev command (defined in eev.el) and the # ee alias (in my .zshrc) to execute parts of this file. # Executing this file as a whole makes no sense. # # Note 2: be VERY careful and make sure you understand what # you're doing. # # Note 3: If you use a shell other than zsh things like |& # and the for loops may not work. # # Note 4: I always run as root. # # Note 5: some parts are too old and don't work anymore. Some # never worked. # # Note 6: the definitions for the find-xxxfile commands are on my # .emacs. # # Note 7: if you see a strange command check my .zshrc -- it may # be defined there as a function or an alias. # # Note 8: the sections without dates are always older than the # sections with dates. # # This file is at <http://angg.twu.net/a/e/http.e> # or at <http://angg.twu.net/e/http.e.html>. # See also <http://angg.twu.net/emacs.html>, # <http://angg.twu.net/a/.emacs[.html]>, # <http://angg.twu.net/a/.zshrc[.html]>, # <http://angg.twu.net/escripts.html>, # and <http://angg.twu.net/>. # ####### ##### # # Apache installation/configuration (basic) # 1999aug09 # ##### apti apache apache-doc # (find-vldifile "apache.list") # (find-fline "/usr/doc/apache/") # (find-vldifile "apache-doc.list") # (find-fline "/usr/doc/apache-doc/") # (find-fline "/etc/apache/httpd.conf" "ServerType") # ServerType standalone # (find-fline "/etc/apache/httpd.conf" "#ServerName host.some_domain.com") # ServerName angg # (find-fline "/etc/apache/srm.conf" "AddHandler cgi-script .cgi") # AddHandler cgi-script .cgi # (find-fline "/etc/apache/access.conf" "\nOptions") # Options Indexes FollowSymLinks ExecCGI /etc/init.d/apache restart # Test if apache is working: # lynx http://127.0.0.1/ ##### # # Test if CGIs are working # (with "showquery"; 1999aug09) # ##### apti data-dumper cd /usr/lib/cgi-bin/ heredoc showquery.cgi -m 0755 \ <<'---' #!/usr/bin/perl # (find-pl5file "CGI.pm") print "Content-type: text/plain\n\n"; use CGI; my $query = new CGI; use Data::Dumper; sub pdump { print "\n$_[0]:\n", Dumper($_[1]); } pdump "ENV", \%ENV; pdump "query", $query; --- lynx $LH/cgi-bin/showquery.cgi'?foo=bar' cd /usr/lib/cgi-bin/ cp -v showquery.cgi /var/www/ lynx $LH/showquery.cgi'?foo=bar' ##### # # wikits as CGIs - short version # 1999aug09 # ##### # «wiki_apache» # (find-es "tcl" "wikit_cgi") cd /var/www/ rm -Rv wikit/ mkdir wikit/ chmod 777 wikit cd /var/www/wikit/ gzip -cd < $S/http/mini.net/cgi-bin/wikit.gz > wikit_cgi chmod 777 wikit_cgi heredoc wikit.cgi -m 0555 <<'---' #!/bin/sh exec /usr/local/bin/tclkit /var/www/wikit/wikit_cgi wikit --- chmod 755 wikit.cgi lynx $LH/wikit/wikit.cgi # (find-fline "/var/log/apache/") # (find-fline "/var/log/apache/error.log") # Comparing conffiles: # cd /o/etc/apache for i in *.conf; do echo "\n\n $i:\n"; diff $i /etc/apache/$i; done # (find-vldifile "" "apache.") # (find-vldifile "apache.list") # (find-fline "/usr/doc/apache/") # A question: if the default for apache is "inetd", shouldn't the port # 80 be trapped by inetd? # Notes on debugging: # # (find-fline "/etc/init.d/apache") # (find-fline "/usr/sbin/apachectl") bash -x /etc/init.d/apache restart bash -x /usr/sbin/apachectl start echo $? /usr/sbin/apache echo $? strace -f -o ~/s /usr/sbin/apache laf /o/etc/apache/ laf /etc/apache/ --> Restarting apache daemon... failed. # (find-fline "/etc/apache/httpd.conf") Uau! ##### # # Apache's main packages # ##### # (find-vldifile "apache.list") # (find-vldifile "apache-common.list") # (find-vldifile "apache-dev.list") # (find-vldifile "apache-doc.list") # (find-fline "/usr/doc/apache/") # (find-fline "/usr/doc/apache-common/") # (find-fline "/usr/doc/apache-dev/") # (find-fline "/usr/doc/apache-doc/") # (find-fline "/usr/doc/apache/examples/") # (find-fline "/usr/doc/apache/examples/printenv") # (find-fline "/usr/doc/apache/examples/test-cgi") apti apache-doc # (find-vldifile "apache-doc.list") # (find-fline "/usr/doc/apache-doc/") edrxnetscape /usr/doc/apache/manual/index.html & # (find-fline "/etc/apache/") # (find-fline "/etc/init.d/apache") bash -x /etc/init.d/apache restart bash -x /etc/init.d/apache reload-modules # (find-fline "/usr/doc/apache/manual/invoking.html" "the files are:") cd /etc/apache/ for i in httpd.conf srm.conf access.conf; do echo "\n $i:" egrep -v "^(#|[ \t]*\$)" $i done # (find-fline "/usr/doc/apache/manual/invoking.html") ####### # # Apache and demo cgis # ####### dpkg -iE apache # # (find-fline "/etc/apache/httpd.conf") # no final: ServerName 0.0.0.0 # (find-fline "/etc/apache/access.conf" "Options Indexes FollowSymLinks") # appendar ExecCGI # (find-fline "/etc/apache/srm.conf" "AddHandler cgi-script .cgi") # (find-esfile "perl.e" "/var/www/perlex/") # ln -sf /usr/bin/perl /usr/local/bin/perl ln -sf ~/mycgis /var/www/mycgis /etc/init.d/apache restart rm -Rv /var/www/perlex/ mkdir /var/www/perlex/ cd /var/www/perlex/ cp -iv /usr/doc/perl/examples/cgi/* . gzip -dv * perl RunMeFirst chmod 755 *.cgi chown edrx:edrx -Rc /var/www/perlex #### # # boa (slink) # 99oct24 # #### # «boa_install» apti boa # (find-vldifile "" "boa") # (find-fline "/etc/init.d/boa") # (find-fline "/sbin/start-stop-daemon" "Usage:") # To keep apache as the default web server: cd /etc find init* rc* | egrep 'boa|apache' find rc* | egrep 'S..boa' rm -v $(find rc* | egrep 'S..boa') /etc/init.d/boa stop /etc/init.d/apache start sleep 1 lsof | grep :www # To let boa be the web server (temporarily): /etc/init.d/apache stop /etc/init.d/boa start lsof | grep :www # (find-es "general" "lsof-2.0.37") ##### # # boa as a secondary web server (slink) # 99oct24 # ##### # «boa_secondary» # See the previous chunk for installation on Debian. # (find-vldifile "boa.list") # (find-fline "/usr/doc/boa/") # (find-fline "/usr/doc/boa/docs/") # (find-fline "/usr/doc/boa/examples/") # (find-fline "/etc/boa/boa.conf") egrep '^#?[A-Z]' /etc/boa/boa.conf |& tee ~/o rm -Rv /tmp/boa/ mkdir /tmp/boa/ cat > /tmp/boa/boa.conf <<'---' Port 8080 User nobody Group nogroup ServerAdmin root@localhost ErrorLog /var/log/boa/error_log AccessLog /var/log/boa/access_log #VerboseCGILogs #ServerName www.your.org.here #VirtualHost #DocumentRoot /var/www DocumentRoot /tmp/boa UserDir public_html DirectoryIndex index.html DirectoryMaker /usr/lib/cgi-bin/boa_indexer KeepAliveMax 100 KeepAliveTimeout 10 MimeTypes /etc/mime.types DefaultType text/plain #AddType application/x-httpd-cgi cgi Alias /doc /usr/doc ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ --- kill $(pidof boa) boa -c /tmp/boa lsof | grep boa cp ~/TH/L/*.html /tmp/boa/ lynx http://angg:8080/ lynx http://angg:8080/cgi-bin/ # lynx complains with "Bad partial reference! Stripping lead dots.". Why? # (find-es "lynx" "lynx_patch_turbo") # (find-fline "/var/log/boa/") # (find-fline "~/EXPECT/") # (find-fline "~/EXPECT/httpc1") cd /usr/src/lynx-2.8.1/ agrep 'Bad partial reference! Stripping lead dots' $(find *) agrep 'BAD_PARTIAL_REFERENCE' $(find *) # (find-lynxfile "src/LYCharUtils.c" "BAD_PARTIAL_REFERENCE") expect -c ' spawn telnet 127.0.0.1 8080 expect -re "Connected to \[^\n\]+\n\[^\n\]+\n" send "GET /index.html HTTP/1.0\n\n" expect eof ' ###### # # boa - recompiling # 99oct24 # ###### pdsc /big/slinks2/dists/slink/main/source/web/boa_0.93.15-1.dsc debian/rules binary |& tee odrb # (code-c-d "boa" "/usr/src/boa-0.93.15/") # (find-boafile "") # (find-boafile "odrb") # (find-boafile "debian/rules") # (find-boafile "src/") ##### # # dustmote # 99nov15 # ##### # «dustmote» # (find-fline "$S/ftp/ftp.unicamp.br/pub/simtelnet/win95/webbrows/dumo104.zip") rm -Rv /usr/src/dustmote/ mkdir /usr/src/dustmote/ cd /usr/src/dustmote/ unzip -a $S/ftp/ftp.unicamp.br/pub/simtelnet/win95/webbrows/dumo104.zip # (find-fline "/usr/src/dustmote/") cd /usr/src/dustmote/ cp dustmote.tcl dm8080.tcl ed dm8080.tcl <<'---' 141c vwait forEver . 1,3c set root /home/root/TH/L set default index.html set port 8080 . w --- tclsh dm8080.tcl |& tee /tmp/odm lsof | grep tcl lynx http://127.0.0.1:8080/ # (find-fline "/usr/src/dustmote/dm8080.tcl") diff -e dustmote.tcl dm8080.tcl (progn (find-fline "/usr/src/dustmote/dustmote.tcl") (indent-region (point-min) (point-max) nil) (save-buffer)) ##### # # http from Tcl # 99nov14 # ##### # «tcl_http» # (find-es "page" "angelfire") # (find-fline "~/TCL/httpwiki") # (find-fline "$S/http/www.angelfire.com/cgi-bin/") expect -c ' set afpasswd xxxxxxxx ;# PUT THE PASSWORD HERE! # package require http 1.0 set answer [http_data [http_get \ https://www.angelfire.com/cgi-bin/bedit -query [http_formatQuery \ fullhpd or2/edrx \ password $afpasswd \ login submit]]] puts $answer ' |& tee /tmp/bedit.html # (find-fline "$S/http/www.angelfire.com/cgi-bin/") # (find-fline "$S/http/www.angelfire.com/cgi-bin/bedit.html") # (find-fline "$S/http/www.angelfire.com/cgi-bin/bedit") # (find-fline "/tmp/bedit.html") lynx /tmp/bedit.html lynx $S/http/www.angelfire.com/cgi-bin/bedit.html cp $S/http/www.angelfire.com/cgi-bin/bedit.html /tmp/bedit.html getforms < /tmp/bedit.html diff /tmp/bedit.html $S/http/www.angelfire.com/cgi-bin/bedit.html agrep -i input /tmp/bedit.html agrep -i input $S/http/www.angelfire.com/cgi-bin/bedit.html cat $S/http/www.angelfire.com/cgi-bin/bedit.html | \ expect -c ' while {[gets stdin li]!=-1} { if {[regexp {<input [^>]*>} $li inp]} { puts $inp } } ' | \ tee ~/o # (find-fline "~/.zshrc" "getforms") getforms < $S/http/www.angelfire.com/cgi-bin/bedit ##### # # Sending and receiving files # 99nov16 # ##### # (find-es "tcl" "cgi.tcl") # (find-cgitclfile "") # (find-cgitclfile "example/") # (find-cgitclfile "example/upload.cgi") # (find-cgitclfile "example/uploadbin.cgi") # (find-fline "/usr/lib/tcl8.0/") # (find-fline "/usr/lib/tcl8.0/http1.0/") # (find-fline "/usr/lib/tcl8.0/http2.0/") # (find-fline "/tmp/upload.html") # (find-fline "/usr/src/dustmote/dm8080.tcl") cd /tmp/ wget -O upload.html http://127.0.0.1/cgi-tcl/upload.cgi edrxnetscape http://127.0.0.1/cgi-tcl/ ##### # # Logging everything on a http connection # 99nov16 # ##### # set info [fconfigure $socketChannel -peername] # set peerName [lindex $info 1] # set when [clock format [clock seconds] ] # puts stdout "$peerName $when" # (find-fline "~/EXPECT/eheaders") # stty -icanon min 1 echo expect -c ' proc answer {socketChannel ip port} { puts "$ip $port" spawn -open $socketChannel interact puts "(closed)" } socket -server answer 8080 vwait forEver ' # On other window: expect -c ' spawn telnet 127.0.0.1 8080 interact timeout 10 exit ' # On still another window: kill $(pidof telnet) ##### # # CGI.pm-2.56 # ##### # «cgipm-2.56» rm -Rv /usr/src/CGI.pm-2.56/ cd /usr/src/ tar -xvzf $SCPAN/authors/id/LDS/CGI.pm-2.56.tar.gz cd /usr/src/CGI.pm-2.56/ # (code-c-d "cgipm" "/usr/src/CGI.pm-2.56/") # (find-cgipmfile "")