felix001 13 Junior Poster in Training

Im trying to run a small python CGI script but when i run it i get the error :

malformed header from script. Bad header=[Querying whois.internic.net]: hello_get.py

The CGI scripts im trying to run are :

#!/usr/bin/python

# Import modules for CGI handling
import cgi, cgitb
import os

# Create instance of FieldStorage
form = cgi.FieldStorage()

# Get data from fields
ip = form.getvalue('ip')

print "Content-Type: text/html; charset=utf-8\n\n";
print "<html>"
print "<head>"
print "<body>"
<pre>
print os.system('whois ip')
print ""
</pre>
print "</body>"
print "</html>"
#!/usr/bin/python
import cgi
print "Content-type: text/html"
print
form = cgi.FieldStorage()
print """
<html>
<body>
<form action="/cgi-bin/hello_get.py" method="get">
IP: <input type="text" name="ip">  <br />
<input type="submit" value="Submit" />
</form>
</body>
</html>"""

Thanks...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.