Puzzling form/cgi problem

Bengt Richter bokr at oz.net
Sun Nov 2 20:13:48 EST 2003


On Mon, 03 Nov 2003 06:23:24 +1000, "Dfenestr8" <chrisdewinN0SPAM at yahoo.com.au> wrote:

>Hi.
>
>I have a problem with a subroutine in a cgi script that's supposed to
>return the byte location at the end of a file, which the script then
>stores as a hidden input on a web form.
>
>Unfortunately, even though it works fine in the python shell, in the
>cgi-script it always returns "0". That's no use to me at all.
>
If you want to use that routine, you might want to return something distinctive in case
of exceptions. E.g., perhaps the cgi prog can't see the file the way you are specifying it
(is it a full path? Is that legal in the context of the cgi, which are sometimes constrained
to access down a particular subtree?) or doesn't have adequate permissions (cgi is probably
running as "nobody" or some other server user id, and running in a different default directory).

>Here's the subroutine......
>
>def getLastByteLoc(log):
>	#open log file
>	f = open(log)
>	
>	#seek to end of log file.
>	f.seek(0,2)
>	
>	location = f.tell()
>	f.close()
>	return location
>

Regards,
Bengt Richter




More information about the Python-list mailing list