GGI works and then doesn't work--global replace (Sivakatirswami)
Sadhunathan Nadesan
sadhu at castandcrew.com
Tue May 21 12:14:01 EDT 2002
| Today's Topics:
|
| 1. GGI works and then doesn't work--global replace (Sivakatirswami)
Swami,
This doesn't solve the problem but may give you a clue? As you know,
the premature end of headers message from apache occurs when the cgi
script returns something that is not html.
In your program it appears that the only way this could happen is if
you got a fatal error prior to getting down to the lines of code that
put the content type, etc. So my first suggestion is - put that stuff
at the very beginning of your program then you might have a chance to
see what is happening (ah, maybe depending on if when the mc
interpreter fails it sends to standard out or standard error, and if
stderr it would be picked up by apache, not sure.)
Of course, if you only had a SHELL account then you could simply trap
the raw input from the get into a file, then test by piping that input
directly into your script and see what error message you are getting
back and then track it down that way. Oh well. I suppose there are
tedious ways around it using SSI.
Anyway, I would ask myself the question - how could a fatal error
possibly occur? Such as, what if variable "y" is empty? or .. etc.
It is always a good practice, IMHO, to initialize variables even
though MC doesn't require it.
Also, I have some shell script code at home that would probably do
your directory walk a lot faster, I'll dig it up and send it later.
Aum Aum
Sadhunathan
|
| --__--__--
|
| Message: 1
| Date: Sun, 19 May 2002 08:04:36 -1000
| Subject: GGI works and then doesn't work--global replace
| From: Sivakatirswami <katir at hindu.org>
| To: Metacard List <metacard at lists.runrev.com>
| Reply-To: metacard at lists.runrev.com
|
| There's a mystery with the following CGI running on a SPARC-Solaris -- two
| questions.
|
| FYI The intent is to have a global search and replace function for strings
| in HTML files.
|
| 1-Mystery... I ran this script using "GET" and about 3 minutes later, after
| processing 792 files it returned "Done." and a manual check of files showed
| that it had succeeded in processing the file.
|
| Then, a few minutes later I changed the text in the string to be replaced
| and, inexplicably, the server returns a configuration error and the error
| log indicates "premature end of script headers" which I know to be a generic
| error message that tells one very little about what actually went wrong.
| Any one have any ideas why it could work the first time and fail the next
| time?
|
| 2) This script is a little slower than expected running on such a powerful
| CPU... though perhaps my expectations are too high... but, is there a better
| strategy, perhaps issuing shell command to get UNIX to do the work? Just
| the directory walk itself to get a file list was fairly time consuming.
|
| #!/export/[snip]/www/public_html/cgi-bin/mc
|
| global gHierList,gMainFolder
|
| on startup
| set the directory to "../" ## gets us up and out of /cgi-bin/
| put the directory into gMainFolder
| directoryWalk gMainFolder
|
| repeat for each line y in gHierList
| ## following line does the work.
| Replace "copyright (C) 2001 Himalayan Academy" with \
| "copyright (C) 2002 Himalayan Academy" in URL ("file:"&y)
| end repeat
| put "done" into buffer
| put "Content-Type: text/plain" & cr
| put "Content-Length:" && the length of buffer & cr & cr
| put buffer
| end startUp
|
| on directoryWalk whatFolder
|
| set the itemDel to "/"
| set the directory to whatFolder
| put the files into temp
| filter temp with "*.html"
| add the number of lines of temp to tCount
| sort temp
| repeat for each line x in temp
| put whatFolder & "/" & x & cr after gHierList
| end repeat
| put the folders into tDirList
| sort tDirList
| delete line 1 of tDirList
| repeat for each line x in tDirList
| if (x = ".." or x = "webmaster") then next repeat
| directoryWalk (whatFolder & "/" & x)
| end repeat
|
| --__--__--
More information about the metacard
mailing list