| | |
simple cgi script issue
Thread Solved |
•
•
Join Date: May 2005
Posts: 8
Reputation:
Solved Threads: 0
Hey there, i need some help with a simple cgi script.
i cannot get it to write output to a file.
here is the script.
it works, in that it returns the correct info to the browser,
but it does not write a text file.
i need to be able with this script to store on my disk what is input
in the html form.
any suggestions ?
Edit/Delete Message
i cannot get it to write output to a file.
here is the script.
Python Syntax (Toggle Plain Text)
#!/usr/bin/python import cgi form = cgi.FieldStorage() Customer = form['Customer'].value Field = form['Field'].value data = [Customer, Field] reshtml = """Content-Type: text/html\n <html> <head><title>Customer Data</title></head> <body> <h1>Customer Data</h1> <p>Here ya go</p> </body> </html>""" print reshtml + 'Customer =' + data[0] print ' ' + ' Field = ' + data[1] # this is where the script fails to do anything.... OutFile = open("/home/nephish/Test.txt", "w") OutFile.write("Here is a spot of text to input") OutFile.close
it works, in that it returns the correct info to the browser,
but it does not write a text file.
i need to be able with this script to store on my disk what is input
in the html form.
any suggestions ?
Edit/Delete Message
I ran a quick test and on my Windows XP Box it seems to be the file path it balks at. I had to give it the full file path (or at least back to where python.exe sits)
python Syntax (Toggle Plain Text)
try: # needs full file path! OutFile = open("/home/nephish/Test.txt", "w") OutFile.write("Here is a spot of text to input") OutFile.close() print "File successfully written" except IOError: print "Cannot open file for writing"
Last edited by vegaseat; Aug 12th, 2009 at 12:49 pm.
May 'the Google' be with you!
![]() |
Similar Threads
- CGI script gathering browser info (C++)
- Formmail cgi script (Perl)
- guestbook cgi script won't return reply page???? (Perl)
- My CGI Script gives me this error...What am I missing? (Perl)
Other Threads in the Python Forum
- Previous Thread: python power
- Next Thread: how do i read the last line of a text file?
| Thread Tools | Search this Thread |
accessdenied advanced aliased argv beginner bits calling casino change changecolor clear command convert corners count csv cturtle cursor def definedlines dictionary digital dynamic dynamically enter event events external file float format frange function google homework i/o iframe import input jaunty java keyboard lapse line linux list lists loop matching microphone mouse multiple newb number numbers obexftp output parameters parsing path port prime programming projects py py2exe pygame pyopengl python random rational raw_input recursion return scrolledtext signal simple singleton skinning sprite string strings tails text threading time tlapse tuple tutorial ubuntu unicode urllib urllib2 valueerror variable voip web-scrape whileloop word wxpython






