Reputation: 455
I have a very simple CGI python server on linux with the following code:
#!/usr/bin/env python
import BaseHTTPServer
import CGIHTTPServer
import cgitb; cgitb.enable() ## This line enables CGI error reporting
server = BaseHTTPServer.HTTPServer
handler = CGIHTTPServer.CGIHTTPRequestHandler
server_address = ("", 8000)
handler.cgi_directories = ["/"]
httpd = server(server_address, handler)
httpd.serve_forever()
In the same directory, I have a script named example-bash.sh. What I want to do is simply be able to display the output of that bash script in the browser when I navigate to localhost:8000/example-bash.sh. When I try, it just opens the file instead of running it.
example-bash simply has the following code:
#!/bin/bash
echo "Content-type: text/html"
echo ''
echo 'CGI Bash Example'
How can I make it run instead?
Upvotes: 5
Views: 3598