need some cgi help please

N

nephish

Hey there. Here is the deal.... i have a script that is supposed to
open a file based on criteria from a web form.
i cant seem to get it to work though.

here is the code:

form = cgi.FieldStorage()
DataRecord = form['DataTime'].value
Customer = form['CustName'].value # should be automatically filled in


print "Content-Type: text/html\n\n"
print

WorkingFile =
open("/var/www/stretch/web_root/SidCrops/"+Customer+"/"+DataRecord,
"r")
all_lines = WorkingFile.readlines()
WorkingFile.close()
for line in all_lines:
print line

here is the error:
WorkingFile undefined, builtin open = <type 'file'>, Customer =
'tenderloin', DataRecord = 'Tue Jun 7 20:13:35 2005.txt'

IOError: [Errno 2] No such file or directory:
'/var/www/stretch/web_root/SidCrops/tenderloin/Tue Jun 7 20:13:35
2005.txt'
args = (2, 'No such file or directory')
errno = 2
filename = '/var/www/stretch/web_root/SidCrops/tenderloin/Tue Jun
7 20:13:35 2005.txt'
strerror = 'No such file or directory'

here is the deal.... the file is there ! i run similar code in idle and
it works.
i just dont get it. it isn't a permissions issue, its chmod 777 all
the way.
i gotta find out why this is goofing on me...

please help me!
 
D

Douglas Soares de Andrade

Hi !

Im a python begginer, but...
form = cgi.FieldStorage()
DataRecord = form['DataTime'].value
Customer = form['CustName'].value # should be automatically filled in

Can you try this ?

print "Content-Type: text/html\n\n"
print

WorkingFile =
open("/var/www/stretch/web_root/SidCrops/"+Customer+"/"+DataRecord,"r")

for line in WorkingFile:
print line

WorkingFile.close()
here is the error:
WorkingFile undefined, builtin open = <type 'file'>, Customer =
'tenderloin', DataRecord = 'Tue Jun 7 20:13:35 2005.txt'

IOError: [Errno 2] No such file or directory:
'/var/www/stretch/web_root/SidCrops/tenderloin/Tue Jun 7 20:13:35
2005.txt'
args = (2, 'No such file or directory')
errno = 2
filename = '/var/www/stretch/web_root/SidCrops/tenderloin/Tue Jun
7 20:13:35 2005.txt'
strerror = 'No such file or directory'

This files

'/var/www/stretch/web_root/SidCrops/tenderloin/Tue Jun 7 20:13:35 2005.txt'

exists ?

See the spaces in the file...
 
G

Greg Ewing

IOError: [Errno 2] No such file or directory:
'/var/www/stretch/web_root/SidCrops/tenderloin/Tue Jun 7 20:13:35
2005.txt'
args = (2, 'No such file or directory')

The web server isn't running in a chrooted environment
or anything, is it?

Are there any other files that it *can* open?
 
N

nephish

i fixed it.
the program was going nuts because there were
spaces in the name of the file.
go figgure.
anyway, i changed the way i format the timestamp that
becomes the file name and removed the spaces.
working all better now.
thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,241
Messages
2,571,219
Members
47,851
Latest member
TheoChestn

Latest Threads

Top