|
Apache on Cygwin
Start apache:
/usr/sbin/httpd
Cd to /var/www/cgi-bin
Reset permissions of test-cgi:
chmod a+x test-cgi
In your browser, type the URL:
127.0.0.1/cgi-bin/test-cgi
This should run the test-cgi script which will report
some details about your operating environment.
Cd to /var/www/htdocs and create a default web page index.html:
Hello World!
Change its permissions:
chmod a+r index.html
In your browser, type the URL:
127.0.0.1
You should see your default page.
To run an executable program, try the following Mumps
script (see http://cns2.uni.edu/~okane/source/MUMPS-MDH/.
Download and install from the highest numbered
mumpscompiler...)
In /var/www/cgi-bin create mtest.mps with the following contents:
zmain
+#include
html Content-type: text/html &!&!
html
html test test test
Compile it:
mumpsc mtest.mps
Its protections should be correct. In the browser, type:
127.0.0.1/cgi-bin/mtest.cgi
You should see "test test test" on a gray screen.
Try a bash script to access PostgreSQL through apache cgi-bin.
Write btest.cgi in /var/www/cgi-bin as follows:
#!/bin/bash
# disable filename globbing
set -f
echo Content-type: text/plain
echo
echo Database test
echo `whoami`
psql -f f1 -d medical
Write the file f1 in /var/www/cgi-bin to contain the lines:
\l
\d
select namelast, namefirst, ptid from ptname;
\q
Set the protections:
chmod a+x btest.cgi
chmod a+r f1
Type the URL:
127.0.0.1/cgi-bin/btest.cgi
Obtaining a command from a web page.
Build an HTML form and put it in /var/www/htdocs:
Hello World
Write a shell script named formtest.cgi to be called by the web server:
#!/bin/bash
set -f
echo Content-type: text/plain
echo
echo Database test
echo `whoami`
echo Command is `fixer.exe`
psql -d medical -c "`fixer.exe`"
Put it in /var/www/cgi-bin with world execute privs.
Write a brief Mumps program named fixer.mps to parse QUERY_STRING:
zmain
+#include
write command,!
Place it in /var/www/cgi-bin, compile it and rename fixer.cgi
to be fixer.exe. Be sure it has world execute privs.
Run the browser on form.html and enter a command:
|