CGI failure Intermittent -- "Can't Open File"

Sannyasin Sivakatirswami katir at hindu.org
Wed Apr 7 18:37:51 EDT 2004


Good intuitive sleuthing, David!

OK I added the expected variable to tResponse being sent back and 
that's very helpful.. what is happening, in either mode of reading 
stndIn... is that the variable that should contain the incoming data is 
completely empty! but, *occasionally* it does work.

Bottom line now seems to be:  POST is failing completely on most 
occasions, either in the client side Rev App which is posting an empty 
string... or on the Darwin side server CGI interpreter which is failing 
to read anything at all from stnIn from the client side Rev App. a) it 
NEVER works if I use the "repeat while len() form b) it works  But it 
does work *sometimes*   Arghh! ;-)

Whether I do either of these:

repeat while length(tIncomingData) >= $CONTENT_LENGTH
    read from stdin for $CONTENT_LENGTH
    put it after tIncomingData
end repeat

put tIncomingData into tCheckRawData
put  urlDecode (tIncomingData)  into tDataIn

--[or:]

--read from stdin until empty
--put it into tCheckRawData
  -- put  urlDecode (it)  into tDataIn

I get the same result

can't open file

/remote-team/   ## this shows that both the tUser and tFilename are 
empty


I also added a data check to put the entire string of urlEncoded data 
into a variable to test at the end and return in the response like 
this:

put the Result & cr & cr & tFilePath & cr & cr & tCheckRawData & cr & 
cr into tResponse

If I use the "repeat while len..." etc style, tCheckRawData contains 
the literal variable "tIncomindData"  which I assume means that 
tIncomindData is, as a container, empty.

if I use the simple 'read from stnin until empty; put it into 
tCheckRawdata"

the response line that should contains that data is completely empty.

Conclusion at this point:

POST is failing completely on most occasions, either in the client side 
Rev App which is posting an empty string... or on the Darwin side 
server CGI interpreter which is failing to read anything at all from 
stnIn from the client side Rev App.  Arghh! ;-)

Ok, what now? I'll move this whole scenario over to our virtual host 
site at mahiai.aloha.net where we have an old version of MC running on 
a solaris... then if it works there we kind of have it isolated to the 
current versions of Rev... OR OSX server version of Apache or Darwin?

Any more suggestions? I REALLY need this to work as our server admin 
has turned off FTP and now this is the only way I can get data in from 
the outside.




On Apr 6, 2004, at 9:23 PM, Dave Cragg wrote:

> 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
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list