Mailing List Archive

beginners Q: CGI and file paths
Hi,
I've written a cgi script that outputs a couple of files.
The default placement is in the cgi-bin directory and
I want them to go elsewhere. I've tried ...

filename = "/proper_path_here/c_list.html"
append = open(filename, 'a')

but putting the path in front of the filename makes no
difference (and doesn't generate an error)
I read thro cgi.py but can't see what to do.
Any help appreciated...
Cheers
John
--
jlittler@silas.cc.monash.edu.au
http://jlittler.cjb.net
http://linuxmusic.cjb.net
beginners Q: CGI and file paths [ In reply to ]
Mr J Littler writes:

> I've written a cgi script that outputs a couple of files.
> The default placement is in the cgi-bin directory and
> I want them to go elsewhere. I've tried ...
>
> filename = "/proper_path_here/c_list.html"
> append = open(filename, 'a')
>
> but putting the path in front of the filename makes no
> difference (and doesn't generate an error)
> I read thro cgi.py but can't see what to do.

Have you checked file / directory permissions? cgis normally run as
"nobody".

- Gordon
beginners Q: CGI and file paths [ In reply to ]
John,

$ pwd
/afs/rcf/user/jmaziarz

$ python
>>> outFile = '/tmp/temp.out'
>>> output = open(outFile, 'w')
>>> output.write('This is my first test...\n')
>>> output.close()

$ more /tmp/temp.out
This is my first test...

$ python
>>> outFile = '/tmp/temp.out'
>>> output = open(outFile, 'a')
>>> output.write('This is my second test...\n')
>>> output.close()

$ more /tmp/temp.out
This is my first test...
This is my second test...

$ python
>>> outFile = '/tmp/temp.out'
>>> output = open(outFile, 'w')
>>> output.write('This is my third test')
>>> output.close()

$ more /tmp/temp.out
This is my third test

Try using single quotes?
-Jer


Mr J Littler wrote:
>
> Hi,
> I've written a cgi script that outputs a couple of files.
> The default placement is in the cgi-bin directory and
> I want them to go elsewhere. I've tried ...
>
> filename = "/proper_path_here/c_list.html"
> append = open(filename, 'a')
>
> but putting the path in front of the filename makes no
> difference (and doesn't generate an error)
> I read thro cgi.py but can't see what to do.
> Any help appreciated...
> Cheers
> John
> --
> jlittler@silas.cc.monash.edu.au
> http://jlittler.cjb.net
> http://linuxmusic.cjb.net