473,771 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

import of 'string' fails in CGI-BIN script...but works in IDLE

Having 'cloned' an existing python script that imports 'string' and
uses "string.rstrip( )" without incident...
I am at a loss to explain why the new 'cloned' script (brief sample
below) continually errors with:
NameError: global name 'string' is not defined
args = ("global name 'string' is not defined",)

when run from the server CGI-BIN.

If the same script is run in 'IDLE' it
works with no problem. Yet, the "import urllib, string" statement is
clearly
present in the script.

I am running Python 2.3.1 on Win 95, using XITAMI as the server.

Troublesome script follows:

#!c:\Python\pyt hon.exe
import cgitb; cgitb.enable()
import traceback, sys, os, cgi
import urllib, string
sys.stderr = sys.stdout
form = cgi.FieldStorag e()
def writeHTML(rec):
print "Content-Type: text/html"
print
print '''
<FORM ACTION="/cgi-bin/dietsys7.py" METHOD="POST">
<CENTER>
<B><INPUT TYPE="SUBMIT" VALUE="Click to Apply Changes"></B><br><br>'''
print '''
<TABLE BORDER=1 BGCOLOR="FFFF99 ">'''
cycle = 1
drptr = 7
for x in range(10):
uvalue = string.rstrip(r ec[drptr]) <-----(** failure occurs
here)
if not ((cycle % 2) == 0):
print '''<TR bgcolor="pink"> <td>'''
else:
print '''<TR bgcolor="yellow "><td>'''
print '''<INPUT TYPE="text" NAME=''' + '"' + 'doctorcode' +
str(cycle) + '"' + ' ' + '''size="36" maxlength="1" value=''' + '"' +
uvalue + '"' + ' ' + '''>'''
print '''<td><b>Docto r Color Code</B></td></tr>'''
cycle = cycle + 1
drptr = drptr + 1
print '''</table></FORM></FONT></BODY></HTML>'''
fileName = os.path. join("c:", "/xitami", "cgi-bin", "dsysmst.da t")
#print 'Globals: ' + str(globals())
#print 'Locals: ' + str(locals())
f = open(fileName, 'rb')
f.seek(-2690,2)
recd = f.read(2690)
if recd[3:7] == '0000':
f.close()
writeHTML(recd)
sys.exit()
else:
print "Did not get utility record"
f.close()
sys.exit()
Jul 18 '05 #1
0 1764

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

Similar topics

97
4439
by: Kjetil Torgrim Homme | last post by:
often when re-factoring code, I need to change the indent level of some chunk of code. due to the lack of an end marker, my Emacs has to use heuristics when re-indenting, and this will occasionally lead to mistakes. of course this is really _my_ fault, not Emacs', but it's annoying all the same. a colleague uses #fi, #yrt etc. to mark the end of blocks, but I don't find this satisfactory since neither Python nor Emacs has any...
1
1338
by: Laszlo Zsolt Nagy | last post by:
Hello all, Can anyone explain this: C:\Python\Projects\DbDesigner>python Python 2.3.4 (#53, May 25 2004, 21:17:02) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from Db.FieldTypes import IdentifierFieldType >>> from Db.FieldTypes import *
0
1414
by: Laszlo Zsolt Nagy | last post by:
> exarkun@boson:~$ cat foo.py > x = 10 > __all__ = > exarkun@boson:~$ cat bar.py > x = 20 > __all__ = > exarkun@boson:~$ python -c "from foo import *; print x" > Traceback (most recent call last): > File "<string>", line 1, in ? > TypeError: attribute name must be string
4
5271
by: N. Graves | last post by:
Thanks for taking the time to read this note. I have a Access inventory collection tool that I have automated to build and Export to a CSV file. In the database I have several fields that are large text fields for comments. When I'm collecting data I have set the <Enter> button to move to next line instead of the default. We are trying to import this CSV data file in to a Remedy SQL server using the Remedy Import tool. This import...
0
1309
by: ColinWard | last post by:
the title is self explanatory. However although I have figured out how to implement the add-in from code, it consistently fails with the message. "There is no active worksheet". I tried opening Excel to the worksheet I want to import and then running the code but it didn't work. I have posted the code in case anyone can spot my error. ---Code Start---- 33230 On Error GoTo CmdOK_Click_Error
4
2240
by: jemptymethod | last post by:
http://htmatters.net/htm/1/2006/01/EIBTI-for-Javascript-explicit-is-better-than-implicit.cfm
10
6189
by: zahy[dot]bnaya[At]gmail[dot]com | last post by:
Hi, I am trying to come up with a c style string reverser, I want it to take 1 argument Altough I would never do this in real life. Is there a way to do it? I wrote this function that fails : Any idea why it fails? char * C_recReverse(char * str)
5
5969
by: Pete Wittig | last post by:
Hi, Here is my problem. I have a serviced component that is exposed via a SOAP interface. This particular component, Person, has a method that takes in another object called PersonHobby. When I try and use wsdl.exe, it always fails on the method "AddHobby" which takes in the PersonHobby. Here is what I enter on the command line: wsdl /out:C:\proxies\Person.cs http://development4/Demo/DAL_Demo.Entities.Person.soap?WSDL
2
3963
by: pendell | last post by:
I am working with a client running 2003 Access. Some time ago I built them an import spec for use with the Import Wizard. Several months later, I have been called back and asked to solve a problem ... they tried to customize the spec and now the Import Wizard always fails on the last step (when one presses the 'finish' button), returning the dialogue box message "Invalid Use of Null". Running some test, I have determined that the...
2
1924
by: Fuzzyman | last post by:
A very odd error with Python 2.5 (both 2.5.1 and 2.5.2 from the official msi installers and running on Vista under Parallels on the Mac). 'import site' fails due to a string in sys.path that contains a huge number of null bytes. The error is actually in ntpath - I adjusted it to print the paths it is working with and a string on encountering the bad path.
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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
10261
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
10103
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
10038
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
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
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...
1
4007
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

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.