14427Re: running scripts from html pages served by thttpd (UNSLUNG 6.8)
- Aug 3, 2006--- In email@example.com, "Rob Conway" <rjconway@...> wrote:
>script to run with root privlidges.
> Is it as simple as saving my bash script as xxx.cgi I want my
I did some tests and it was quite esy to run a shell script as a .cgi
under thttpd. These are the steps I had to follow:
- make sure your script starts with "#!/bin/sh", so it can be
identified as a shell script that could be run directly;
- make sure your script has a name ending in ".cgi", this is a
requirement from the thttpd configuration under Unslung;
- put your script under /home/httpd/html, or better, under
/home/httpd/html/Management, together with the other cgi programs;
- make sure the permissions for the script are 755 (-rwxr-xr-x), so do
not forget to "chmod 755 your.cgi".
For a quick test, you can copy the following script, paste it into an
editor and save it as /home/httpd/html/Management/test.cgi. It is
actually the test-cgi script from the default Apache distribution, but
it runs perfectly under thttpd. Save it as test.cgi, adjust its
permissions ("chmod 755 test.cgi") then point your browser to
# disable filename globbing
echo Content-type: text/plain
echo CGI/1.0 test script report:
echo argc is $#. argv is "$*".
echo SERVER_SOFTWARE = $SERVER_SOFTWARE
echo SERVER_NAME = $SERVER_NAME
echo GATEWAY_INTERFACE = $GATEWAY_INTERFACE
echo SERVER_PROTOCOL = $SERVER_PROTOCOL
echo SERVER_PORT = $SERVER_PORT
echo REQUEST_METHOD = $REQUEST_METHOD
echo HTTP_ACCEPT = "$HTTP_ACCEPT"
echo PATH_INFO = "$PATH_INFO"
echo PATH_TRANSLATED = "$PATH_TRANSLATED"
echo SCRIPT_NAME = "$SCRIPT_NAME"
echo QUERY_STRING = "$QUERY_STRING"
echo REMOTE_HOST = $REMOTE_HOST
echo REMOTE_ADDR = $REMOTE_ADDR
echo REMOTE_USER = $REMOTE_USER
echo AUTH_TYPE = $AUTH_TYPE
echo CONTENT_TYPE = $CONTENT_TYPE
echo CONTENT_LENGTH = $CONTENT_LENGTH
- << Previous post in topic Next post in topic >>