#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Location
    Italy
    Posts
    27
    Rep Power
    0

    How can send output of my interpreter to the browser?


    Hi, sorry for my english and i hope to post in the right place.

    My question is simple (i hope). I had wrote an interpreted line command web language based on C.

    I had configured Apache cgi-bin to execute scripts. In the cgi-bin dir, Perl and Python scripts working fine but my own scripts show always this error:

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.


    The first line that run the language interpreter I'm sure is correct... what's wrong? What I must to set or send to the browser exactly?
  2. #2
  3. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,095
    Rep Power
    1990
    What does the error message in the log file say?

    For an "Internal Server Error" message it normally means that something isn't configured correctly in the server software, or that the server software doesn't know what you want it to do from your request. Unfortunately that's about all that we can tell you without knowing what the actual error is.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Location
    Italy
    Posts
    27
    Rep Power
    0
    That's right.

    Some more info....

    this is the error line in the Apache Log:

    [Fri Feb 03 10:54:50 2012] [error] [client 127.0.0.1] malformed header from script. Bad header=ciao: demo.bpl

    (I understand something wrong with header but I don't know what and what to pass to...)

    This is the first line I use to execute the script:

    My lang: #!c:/NEWLANG/compiler.exe
    Perl: #!c:/Perl64/bin/perl.exe
    Python: #!c:/Python27/python.exe

    My script use 1 only line after first one:

    Code:
    #!c:/NEWLANG/compiler.exe
    echo "ciao"
    Like web server I use WAMP in localhost with Apache 2.2.11.

  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Location
    Italy
    Posts
    27
    Rep Power
    0
    Some other tests....

    If I put only this lines in the script:

    Code:
    #!c:/NEWLANG/compiler.exe
    
    echo "Content-type: text/html"
    The error message in the Apache log is:

    [Fri Feb 03 12:33:27 2012] [error] [client 127.0.0.1] Premature end of script headers: demo.bpl

    ... something in missing... what???
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Location
    Italy
    Posts
    27
    Rep Power
    0
    I found the problem!

    At the end of my function, inside the compiler, I add only 1 "\n" line feed. I need to add 2 line feed "\n\n" between the "Content type..." and the commands lines of the script (echo).

    Now in the compiler I have this:

    Code:
    printf("\n\n");
    at the end of function echo.

    This because CGI Content needs an empty line after "Content type..." command ...

    ty

IMN logo majestic logo threadwatch logo seochat tools logo