I have this hello_world.py script which takes username and password and prints user information. Separately the python executes without any error. But, when I submit from HTML the html page gives internal server 500 error. I have added executable permission to script in file system, in httpd.conf. But, I am not sure why this is not executing when I provide submit.
Thanks for suggestions and help.
<form action="/cgi-bin/hello_world.py" method="post">
IP Address: <input type="text" name="user_name"><br />
Password: <input type="text" name="pass_word" />
<input type="submit" value="Submit" />
</form>
My python script is
#!/usr/bin/python
# Import modules for CGI handling
import cgi, cgitb
import getpass
import sys
import telnetlib
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from fields
user_name = form.getvalue('user_name')
//username will get IP of machine
pass_word = form.getvalue('pass_word')
loginid = 'admin'
tc = telnetlib.Telnet(user_name)
tc.read_until("login: ")
tc.write(loginid + "\n")
tc.read_until("Password: ")
tc.write(pass_word + "\r\n")
tc.write("ls -l\n")
tc.write("exit\n")
print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>"
print "<title>Hello </title>"
print "</head>"
print "<body>"
print "<h2> %s is IP and %s is passowrd</h2>" % (user_name, pass_word)
print tc.read_all()
print "</body>"
print "</html>"