Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Linux CGI problem

 [1/11] from: rebol665::ifrance::com at: 2-Jun-2002 23:46


Hi rebollers, I am trying to run a very simple CGI script with Apache 1.3.23 under Linux. 1. This script starts with the following two lines #!/home/pat665/core/rebol -cs rebol [] 2. The script is called from 192.168.1.52 under IE (Windows machine) with http://192.168.1.51/cgi-bin/cgi-hw.cgi 3. Inside the browser, I got only one word for response REBOL 4. Using proxy.r with debug-all set to true, I am able to see what I am getting from Apache. {HTTP/1.1 200 OK^M Date: Sun, 02 Jun 2002 21:31:02 GMT^M Server: Apache-AdvancedExtranetServer/1.3.23 (Mandrake Linux/4mdk)^M The command line usage is: ^M Connection: close^M Content-Type: text/plain^M ^M ^-REBOL <options> <script> <arguments> All fields are optional. Supported options are: ^---cgi (-c) Check for CGI input ^---do expr Evaluate expression ^---link url Connect to Link ( etc ) 5. In fact, I am getting the REBOL syntax for the command line 6. On the Linux machine (192.168.1.51) I got the same result with http://localhost/cgi-bin/cgi-hw.cgi . 7. From the console, I can start the script with this command line /var/www/cgi-bin/cgi-hw.cgi The result is again a remainder of the REBOL syntax for the command line except that it is not displayed in Mozilla but on the console. I am at a loss. Any idea, any debugging tips will be greatly appreciated ... Patrick

 [2/11] from: gchiu:compkarori at: 3-Jun-2002 20:11


hi Pat, I've seen this problem when the cgi script has not been detabbed, or has otherwise been uploaded as binary rather than text. -- Graham Chiu

 [3/11] from: rebol665:ifrance at: 3-Jun-2002 14:04


Hi Graham I have deleted all the TAB in my script with no result. Is there something to do to the file (like chown or chmod) ? The file already 777 and belongs to apache:apache. Patrick

 [4/11] from: athiele:charter at: 3-Jun-2002 13:41


Can you run other cgi scripts ? There should be a test cgi in the cgi-bin. Which version of Apache are you using ? Adrian

 [5/11] from: jason:cunliffe:verizon at: 3-Jun-2002 11:15


> 3. Inside the browser, I got only one word for response > > REBOL
Not sure if this helps or not... What is your script? Is it trying to return something to display to the browser? If so, then you need some kind of http header at the beginning of your script, or the browser won't see anything. Common ones are: textheader: "Content-Type: text/plain^/" htmlheader: "Content-Type: text/html^/" jsheader: "Content-type: script/javascript^/" xmlheader: "Content-Type: text/xml^/" print htmlheader ;; or another one, then your code below etc... But even if it your script is not rendering HTML, you do need to make sure you CAN do that to help reveal other problems. Have you written a minimal hello.r script ? %hello.r ----------------------------------- #!/home/pat665/core/rebol -cs REBOL [] print "Content-type: text/html^/^/" print "hello" ----------------------------------- If that works, then spiff it up by defining and ordering REBOL words for the essential HTML tags: <html><head><title></title></head><body></body></html>. Then insert some local task, like listing the current directory in between the <body></body> tags: ;list-directory result: make string! 256 dir: copy [] dir: read %. foreach file dir [ append result rejoin [file "<br>"]] print result Turn it into a function and then factor it out, saving to a separate script %list-directory.r. Test manually in both Linux and REBOL shells. Then load it in %hello.r and test it there.. Also keep a Linux shell opens and run this Apache error check often to see what Apache is saying and doing: tail -20 /var/log/httpd/error_log # <<== or wherever your Apache log is If you get this message in error_log: [Wed Apr 10 14:05:14 2002] [error] [client 172.30.8.19] Premature end of script headers: /var/www/cgi-bin/somescript.r ...then its a Linux permission problem. Usually your script is not running as the right user, or its trying to do something it's not allowed to do, like read/write to a directory its shouldn't. A helpful test can be to write a utility HTML page to expose REBOL's system/options/cgi If you have PHP installed, I have also found it helpful to use that, since it is so nicely integrated with Apache. The simplest PHP cgi magic I know is: info.php ---------- <? phpinfo(); ?> ---------- That returns a magnificent table including a section "Apache Environment". It would be nice if REBOL bundled such a sweet tiny cgi tool to help people get up and running on servers. hth ./Jason

 [6/11] from: nitsch-lists:netcologne at: 3-Jun-2002 18:09


Am Montag, 3. Juni 2002 10:11 schrieb Graham Chiu:
> hi Pat, > > I've seen this problem when the cgi script has not been > detabbed, or has otherwise been uploaded as binary rather > than text.
i had that problem when uploading as binary with windows with /core 2.5 . found windows used crlf as line-terminator. rebol parsed upto lf, so had cr in the argument. and was not happy about it. -volker

 [7/11] from: rebol665:ifrance at: 3-Jun-2002 17:39


Hi Adrian Apache version is 1.3.23 and test-cgi runs fine and gives : CGI/1.0 test script report: argc is 0. argv is . SERVER_SOFTWARE = Apache-AdvancedExtranetServer/1.3.23 (Mandrake Linux/4mdk) SERVER_NAME = PORTABLEPPH.PCSDEV.NET GATEWAY_INTERFACE = CGI/1.1 SERVER_PROTOCOL = HTTP/1.1 SERVER_PORT = 80 REQUEST_METHOD = GET HTTP_ACCEPT = image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-excel, */* PATH_INFO PATH_TRANSLATED SCRIPT_NAME = /cgi-bin/test-cgi QUERY_STRING REMOTE_HOST REMOTE_ADDR = 192.168.1.56 REMOTE_USER AUTH_TYPE CONTENT_TYPE CONTENT_LENGTH Patrick

 [8/11] from: rebol665:ifrance at: 4-Jun-2002 8:53


Hi Volker and Graham Volker said
>i had that problem when uploading as binary with windows with /core 2.5 . >found windows used crlf as line-terminator. >rebol parsed upto lf, so had cr in the argument. >and was not happy about it.
Yes it was exactly that. An open/save from the rebol editor has fixed the problem. I will remember the lesson. Patrick

 [9/11] from: anton:lexicon at: 4-Jun-2002 18:35


You can most probably do the same with write file read file Anton.

 [10/11] from: rebol665:ifrance at: 4-Jun-2002 12:50


Hi Anton, You are rigth. What is funny is that my problem had nothing to do with CGI or Apache. I had read warning about the CR/LF problem, but it is something you skip until you are at it. Patrick

 [11/11] from: a:none:email:it at: 4-Jun-2002 16:47


The is a dos2unix / unix2dos utility for such occasions as well. I forget the exact name but you could also use a quick sed script to handle the same. If you need one let me know and I`ll get you a quick and dirty Sed script. Adrian ----- Original Message ----- From: "rebol665" <[rebol665--ifrance--com]> To: <[rebol-list--rebol--com]> Sent: Tuesday, June 04, 2002 7:50 AM Subject: [REBOL] Re: Linux CGI problem
> Hi Anton, > > You are rigth. What is funny is that my problem had nothing to do with CGI
or Apache. I had read warning about the CR/LF problem, but it is something you skip until you are at it.
> Patrick > >You can most probably do the same with
<<quoted lines omitted: 8>>
> >> > >> >i had that problem when uploading as binary with windows with /core
2.5 .
> >> >found windows used crlf as line-terminator. > >> >rebol parsed upto lf, so had cr in the argument.
<<quoted lines omitted: 9>>
> >[rebol-request--rebol--com] with "unsubscribe" in the > >subject, without the quotes.
____________________________________________________________________________ __
> ifrance.com, l'email gratuit le plus complet de l'Internet ! > vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
<<quoted lines omitted: 3>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Prendi GRATIS l'email universale che... risparmia: http://www.email.it/f Sponsor: Vuoi portarti la discoteca a casa? Prova a farlo partecipando al concorso che mette in palio favolosi Hi-Fi e Radioregistratori CD Philips: Clicca qui: http://adv2.email.it/cgi-bin/foclick.cgi?mid=539&d=4-6

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted