0

I have two CGI test scripts in lighttpd.

When I open Bash http://host/cgi-bin/test.sh URL I get a valid response from the script.

But when I open Python http://host/cgi-bin/test.py the file is downloaded in browser instead of being run by CGI module.

How can I make both Bash and Python work in CGI?

My CGI configuration in lighttpd.conf:

server.modules              = (
                                "mod_access",
                                "mod_cgi",
                                "mod_accesslog" )

cgi.assign = ( ".sh" => "/bin/bash", 
               ".py" => "/usr/bin/python" )

$HTTP["url"] =~ "^/cgi-bin/" {
    cgi.assign = (  ".sh" => "/bin/bash", 
                    ".py" => "/usr/bin/python" )
}

Both files have the same permissions and execute from command line as expected.

$ ls -l /www/pages/cgi-bin/
total 8
-rwxr-xr-x 1 root root 96 May  8 12:27 test.py
-rwxr-xr-x 1 root root 19 May  8 12:19 test.sh

$ cat test.sh         
#!/bin/bash                                                 
echo Hi from Bash                                           
                                                            
$ cat test.py         
#!/usr/bin/python                                           
print "Hi from Python"                                      
$                     
2
  • as a test, reverse the order inside cgi.assign May 8 at 13:12
  • @JaromandaX Nope, does not help.
    – jackhab
    May 8 at 16:48

1 Answer 1

0

Make sure that you have restarted your lighttpd server after changing the configuration.

killall -USR1 lighttpd

Also, make sure you clear your browser's cache, or test in a Private Browsing or Incognito window. Or test on a different machine. Or use a command line client such as curl to test.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .