Loading ...
Sorry, an error occurred while loading the content.

14427Re: running scripts from html pages served by thttpd (UNSLUNG 6.8)

Expand Messages
  • Fernando Carolo
    Aug 3, 2006
    • 0 Attachment
      --- In nslu2-linux@yahoogroups.com, "Rob Conway" <rjconway@...> wrote:
      >
      > Is it as simple as saving my bash script as xxx.cgi I want my
      script to run with root privlidges.

      Rob,

      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
      http://your_slug/Management/test.cgi.

      Regards,

      Fernando Carolo

      -----8<-----cut here-----8<-----
      #!/bin/sh
      # disable filename globbing
      set -f

      echo Content-type: text/plain
      echo

      echo CGI/1.0 test script report:
      echo

      echo argc is $#. argv is "$*".
      echo

      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
      -----8<-----cut here-----8<-----
    • Show all 6 messages in this topic