473,805 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CGI python use "under a curse"

While waiting for my paid-for web-hosting company to get back to me
about my difficulties running python scripts on their servers...
http://groups.google.com/group/comp....f805bf283acc15
....I went and found a free one as a stopgap. And it worked! I was as
happy as a clam. But then it stopped working. Ah. I stripped the
script down to the same minimalist hello-world effort I used
previously:

#!/usr/local/bin/python
import cgi
print "Content-type: text/html\n"
form = cgi.FieldStorag e()
print form["essay"].value

(page here: http://essays.profusehost.net/)

As before, this should print out the contents of a textarea going by
the name of "essay". But it does nothing but throw internal server
errors. The support guy looked at it and gave me this:

Traceback (most recent call last):
File "python1.cg i", line 6, in ?
print form["essay"].value
File "/usr/local/lib/python2.4/cgi.py", line 559, in __getitem__
raise KeyError, key
KeyError: 'essay'

(http://www.profusehost.net/forum/sup...cgi-blink.html)

He says I have a syntax error, though I'm b*ed if I can see where it
could be. Can anyone here suggest anything?

TIA for your forbearance etc.

May 7 '07 #1
3 2850
On Sun, 06 May 2007 21:30:16 -0700, Adrian Smith wrote:
The support guy looked at it and gave me this:

Traceback (most recent call last):
File "python1.cg i", line 6, in ?
print form["essay"].value
File "/usr/local/lib/python2.4/cgi.py", line 559, in __getitem__ raise
KeyError, key
KeyError: 'essay'

(http://www.profusehost.net/forum/sup...cgi-blink.html)

He says I have a syntax error, though I'm b*ed if I can see where it
could be. Can anyone here suggest anything?

Oh lordy lordy lordy, you've got one fine example of incompetence in
action.

From the support forum:

[quote]
Quote:
perl python1.cgi
\Semicolon seems to be missing at python1.cgi line 3.
syntax error at python1.cgi line 4, near "form "
Execution of python1.cgi aborted due to compilation errors.

Quote:
perl -p python1.cgi
Semicolon seems to be missing at python1.cgi line 3.
syntax error at python1.cgi line 4, near "form "
Execution of python1.cgi aborted due to compilation errors.
[end quote]

The "administra tor" John is trying to execute a Python script with Perl.
I notice that you pointed that out to him, and his response was:

[quote]
Sorry for delay. if we try to run this script by python we will get same
error.

python -t python1.cgi
Content-type: text/html

Traceback (most recent call last):
File "python1.cg i", line 6, in ?
print form["essay"].value
File "/usr/local/lib/python2.4/cgi.py", line 559, in __getitem__
raise KeyError, key
KeyError: 'essay'

we can test perl or cgi scripts using perl command.

PLease fix syntax error so it will work fine.
[end quote]

It is NOT the same error. There are NO syntax errors in the script, there
is a runtime error. The so-called administrator is wrong: you can't use
Perl to test just any old CGI scripts. They have to be written in Perl.
I see from the source code on your page that you have a line:

<TEXTAREA NAME="essay" COLS=60 ROWS=20 WRAP=HARD></TEXTAREA>

You have two lines in your cgi script:

form = cgi.FieldStorag e()
print form["essay"].value

Having never done cgi programming, I'm not sure what the problem is, but
after reading help(cgi) I'll take a stab in the dark and say try this:

print form.value

It might also help for you to try this:

print form.keys()
Good luck with the "admins" at your hosting company.

--
Steven.
May 7 '07 #2
On May 7, 2:30 pm, Steven D'Aprano
<ste...@REMOVE. THIS.cybersourc e.com.auwrote:
On Sun, 06 May 2007 21:30:16 -0700, Adrian Smith wrote:
It is NOT the same error. There are NO syntax errors in the script, there
is a runtime error. The so-called administrator is wrong: you can't use
Perl to test just any old CGI scripts. They have to be written in Perl.
Well, I thought that, but you know what happens to newbies who come
out with such opinions forcefully. Maybe they have special magic perl
which parses python.
I see from the source code on your page that you have a line:

<TEXTAREA NAME="essay" COLS=60 ROWS=20 WRAP=HARD></TEXTAREA>

You have two lines in your cgi script:

form = cgi.FieldStorag e()
print form["essay"].value

Having never done cgi programming, I'm not sure what the problem is, but
after reading help(cgi) I'll take a stab in the dark and say try this:

print form.value

It might also help for you to try this:

print form.keys()
Both give me the same ISE, alas.
Good luck with the "admins" at your hosting company.
Well, it *is* free, and there aren't that many free ones that offer
Python. My paid-for host has sent me a message to say they're
ruminating on my issues, though, so I live in hope.

May 7 '07 #3
Adrian Smith wrote:
On May 7, 2:30 pm, Steven D'Aprano
<ste...@REMOVE. THIS.cybersourc e.com.auwrote:
>On Sun, 06 May 2007 21:30:16 -0700, Adrian Smith wrote:
>It is NOT the same error. There are NO syntax errors in the script, there
is a runtime error. The so-called administrator is wrong: you can't use
Perl to test just any old CGI scripts. They have to be written in Perl.

Well, I thought that, but you know what happens to newbies who come
out with such opinions forcefully. Maybe they have special magic perl
which parses python.
>I see from the source code on your page that you have a line:

<TEXTAREA NAME="essay" COLS=60 ROWS=20 WRAP=HARD></TEXTAREA>

You have two lines in your cgi script:

form = cgi.FieldStorag e()
print form["essay"].value

Having never done cgi programming, I'm not sure what the problem is, but
after reading help(cgi) I'll take a stab in the dark and say try this:

print form.value

It might also help for you to try this:

print form.keys()

Both give me the same ISE, alas.
>Good luck with the "admins" at your hosting company.

Well, it *is* free, and there aren't that many free ones that offer
Python. My paid-for host has sent me a message to say they're
ruminating on my issues, though, so I live in hope.
I'd go to Cornerhost. You can get a cheap account there and the support
is friendly and knowledgable. I am no longer a customer and do not stand
to gain by this recommendation, but they are a small business that were
very helpful to me when I *was* a customer.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
------------------ Asciimercial ---------------------
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogs pot.com squidoo.com/pythonology
tagged items: del.icio.us/steve.holden/python
All these services currently offer free registration!
-------------- Thank You for Reading ----------------

May 7 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2551
by: wildchild | last post by:
Hi, I am new to grpahics progamming in/under Borland C. I have included the "graphics.h" header file but i am unable to take input on the screen. if i try to move my cursor to a specified position using gotoxy() function the pointer doesnt moves to the specified location and starts taking input at (1,1) coordiante. Plz help! Thankyou!
5
2025
by: TPS | last post by:
When I set trace enable to true in my web.config file, the debug info does not display at the "bottom" of the page, it displays "under" all of my buttons, labels, grids etc. This behavior happens in GridLayout, or FlowLayout. ? Thanks, TPS.
0
1980
by: lisseut | last post by:
Hi, hope I'm posting to the right forum. I'm using C# under .NET 1.1, Windows XP SP2 I have a form and I've overridden WndProc to print to a text box whenever it receives the WM_NCMOUSELEAVE message. Under "Windows XP Style", I get these messages fine (when the mouse moves off the title bar or form borders). Under "Windows Classic Style", I don't get the message at all! Has anyone seen this?
1
1548
by: pirunnyrkki | last post by:
Being utterly useless when it comes to JavaScript, I come here for help with an issue that may or may not be an actual problem. Say for example that I have a link that looks like thus: <a href="language/lordprayer.html" title="A translation of the Lord's Prayer into Norda&thorn; and other Germanic languages in a side-by-side comparison">The Lord's Prayer</a> Is there a way that I can take this title attribute show up under the...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10607
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10359
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10104
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5541
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3843
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.