CGI failure Intermittent -- "Can't Open File"
Dave Cragg
dcragg at lacscentre.co.uk
Wed Apr 7 03:23:48 EDT 2004
At 6:49 pm -1000 6/4/04, Sannyasin Sivakatirswami wrote:
>Simply stated: the CGI accepts incoming data from a POST and writes
>it to a file sometimes and sometimes it says it can't open the file.
>No pattern...
>
>CONTEXT:
<snip>
>
>the CGI (truncated a bit for email purposes:) goes like this:
>
>on startup
>
>if $REQUEST_METHOD is "POST" then
>read from stdin until empty
> put urlDecode (it) into tDataIn
> split tDataIn by "&" and "="
> put tDataIn["_remotestaff"] into tUser
> put tDataIn["_project"] into tProject
> put tDataIn["_transcript"] into tTranscript
> put tDataIn["_fileName"] into tfileName
>put url "file:transcriptionTeam.txt" into tAuthenticate
>if (tUser is among the lines of tAuthenticate) then
> # set up a file path to the incoming transcription
> # it will just be a small xml file
> switch tProject
> case "taka"
> put "/taka/New-Not Yet Posted/" into tLocalDestination
> break
> case "gita"
> put "/gita/new_incoming/" into tLocalDestination
> break
> end switch
> put ("../remote-team/" & tUser & tLocalDestination & tFileName)
>into tFilePath
>
> # next: open, write data and close the file
>## !! but here is the problem:
>## this attempt to write a file fails intermittently...
># sometimes apache writes the file
># other times it returns "can't open file" to the result
>
>put tTranscript into url ("file:" & tFilePath) ## fails intermittently
>
>put the Result & cr & cr into tResponse # sometimes empty some times
>"can't open file"
>
>## send stuff back to the user to confirm, along with the result
>
>end start up
>
>What is happening is when then the user clicks the button in the
>remote rev app, to trigger the upload to Kauai it may return result:
>"can't open file" then he clicks again and this time gets no result
>and the file is written.
One thing you might want to check first is that the CGI is reading in
all the data.
repeat while length(tDatain) >= $CONTENT_LENGTH
read from stdin for $CONTENT_LENGTH
put it after tDatain
end repeat
I can't say for sure, but looking quickly at your code, it seems you
might get the error you described if the tUser variable was in fact
empty and the tAuthenticate variable contained an empty line. You
could check this by returning tFilePath when you get an error to see
if the file path is the one you expect.
Cheers
Dave
More information about the use-livecode
mailing list