Announcement

Collapse
No announcement yet.

PB not working in NT webserver

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PB not working in NT webserver

    Dear friends,

    I made an astronomical application in PB 3.2 DOS to be used in a webserver.
    I had my site in a Linux server, but in order to be able to run exe files I changed to a NT one.

    The problem is each time I try to run the program, I get a 500 internal error server.
    The program seems to be fine - it runs in my windows computer.

    I think the problem might be the paths to the files. I even tryed to capture the error with an "on error goto" where I try to write to a file the ERR value.

    Do you have any ideas?

    Best regards,

    Rui Fernandes

    ------------------
    Kepler
    Kepler

  • #2
    CGI and web server configurations are far from being my speciality, but I'm thinking that you should start out by having the app report the CURDIR$ string to see if the current directory is where you think it is. This could be important if you are using relative paths in file I/O statements. You'll probably need to pump that information out through STDOUT since writing to a file does not appear to be working for you yet.

    Also, since most web servers tend to launch CGI apps as a seperate Process with quite restricted machine access rights/privileges, it could be that you have to configure the server to allow that app to have read and write disk access, etc. Your servers documentation should address these kinds of issues.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      See your web server docs for more information on the 500 error.

      ------------------
      Tom Hanlin
      PowerBASIC Staff

      Comment


      • #4
        The 500 error is mostly created when the script is looping for too long and the server is killing it.
        In some occasions, it could also mean that the script produced no output.

        Is a simple "Hello world!" script working?
        You should try to get this working first.
        It could also be an interesting thing to print out the environment.
        You could also print the environment to a local file (use absolute paths like c:\test.txt !!! and put a time stamp in it)

        See http://web.verfaillie.com/webserver for some help getting started.
        In the chapter "user interaction" there is a small source example how to display the environment.

        If you are using NT, check that the webserver is running as LOCAL SYSTEM and that the scripts are set to run in the same context.
        This will give your script access to all local resources.

        A last note: your code is DOS code. I'm not sure it will run in the windows environment, like a PBCC application.
        Maybe you will have to create a DOS wrapper for it:
        COMMAND /c myscript.exe (use absolute paths)
        But this makes it very awkward to write cgi applications, besides the time it takes to load command ...

        ------------------
        mailto:[email protected][email protected]</A> www.verfaillie.com www.idemdito.org



        [This message has been edited by Marc Doigny (edited September 28, 2003).]
        [email protected] | Zeepreventorium De Haan | Portraitfotografie | Home server

        Comment


        • #5
          Dear Mark,

          I've tryed everything to make the application work. But it seems there's a problem with the server. I made a program with the following code:

          '----- put compiler metastatements here
          $OPTIMIZE SPEED
          $CPU 8086
          $COMPILE EXE
          $FLOAT EMULATE
          $LIB IPRINT ON
          $STRING 32
          $STACK 2048
          $DIM ALL
          $HUGE
          $OPTION CNTLBREAK ON
          '---------------------------------------------------------------------------

          '----- these lines maintain the current DOS colors
          '----- of the character at location 2,2
          'DIM attribut AS INTEGER
          'attribut = screen(2,2,1)
          'COLOR attribut MOD 16, attribut\16, 0

          '----- Write a fingerprint to the screen.

          DIM path AS STRING
          DIM filename AS STRING

          path = CURDIR$


          filename = path + "\" + "results.htm"
          OPEN filename FOR OUTPUT AS #2
          PRINT #2, path
          CLOSE

          END

          'End of program

          compile it under PB 3.5 DOS and it didn't run. Just a 500 internal server error.

          Best regards,

          Rui Fernandes


          ------------------
          Kepler
          Kepler

          Comment


          • #6
            My understanding is that CGI apps normally return their page data through STDOUT, which the server then picks up and sends to the remote client.

            Unlike PB/DOS 3.5, PB/DOS 3.2 does not include a built-in STDOUT statement, so 3.2 code would probably need to use a discrete STDOUT function, such as can be found in DOSUNIT.BAS.

            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              Your webserver expects some output to be displayed to the user.
              I don't know which server you are using.
              The one i use put the name of the file to be used in the ENVIRONMENT

              ...
              filename$ = ENVIRON$("CGI_STDOUT")
              OPEN filename$ FOR OUTPUT AS #1
              PRINT #1, "<html><body><h1>Hello world !</h1></body></html>"
              ...


              Some other webservers put the names of the files in the COMMANDSTRING
              Your script is called as

              myscript.exe "QueryStringFile.tmp" "ExpectedOutputFile.tmp"

              and your program has to parse the name of the file to use out of the commandstring.


              But first you have to check if your script is excecuted.
              Does you server contain a file named "result.htm" anywhere?
              If not, your webserver has trouble locating your executable and could not execute it.
              Normally, your server should issue a 404 instad of a 500 error message in this case.


              ------------------
              mailto:[email protected][email protected]</A> www.verfaillie.com www.idemdito.org

              [This message has been edited by Marc Doigny (edited September 29, 2003).]
              [email protected] | Zeepreventorium De Haan | Portraitfotografie | Home server

              Comment


              • #8
                Hi,

                I've tryed the following code as you suggested:

                '---------------------------------------------------------------------------
                '----- Program EPHEM.BAS
                '----- Novo Milénio - New Millennium
                '----- Setembro de 2003
                '----- Versão 1.0
                '---------------------------------------------------------------------------

                '----- put compiler metastatements here
                $OPTIMIZE SPEED
                $CPU 8086
                $COMPILE EXE
                $FLOAT EMULATE
                $LIB IPRINT ON
                $STRING 32
                $STACK 2048
                $DIM ALL
                $HUGE
                $OPTION CNTLBREAK ON

                '----- Write a fingerprint to the screen.
                DIM FILENAME AS STRING

                FILENAME = ENVIRON$("CGI_STDOUT")
                OPEN FILENAME$ FOR OUTPUT AS #1
                PRINT #1, "<html><body><h1>Hello world !</h1></body></html>"
                CLOSE

                END


                and, again, returned a 500 internal error.

                Best regards,

                ------------------
                Kepler
                Kepler

                Comment


                • #9
                  First, are you sure the app is even being executed?

                  Does FILENAME$ (in the code above) actually contain a valid file name at run-time? (ie, you need to verify the environment string, etc).

                  Finally, with $ERROR ALL ON added, are any run-time errors occuring? You'll probably want to add code to detect & log the error(s).


                  ------------------
                  Lance
                  PowerBASIC Support
                  mailto:[email protected][email protected]</A>
                  Lance
                  mailto:[email protected]

                  Comment


                  • #10
                    I'm assuming this is a CGI applications...if I remember correctly
                    don't CGI apps need to return the below code first to work?

                    Code:
                    "HTTP/1.1 200 OK"
                    "Content-type: text/html"
                    $CRLF

                    ------------------
                    Every day I try to learn one thing new,
                    but new things to learn are increasing exponentially.
                    At this rate I’m becoming an idiot faster and faster !!!
                    ------------------
                    George W. Bleck
                    Lead Computer Systems Engineer
                    KeySpan Corporation
                    My Email
                    <b>George W. Bleck</b>
                    <img src='http://www.blecktech.com/myemail.gif'>

                    Comment


                    • #11
                      I would strongly advise you to go back to Linux, and code your application in a language such as PHP (or stay on IIS and use ASP.net or something) that can be integrated into the web server. This eliminates the overhead of CGI and is much easier to deal with than an external compiled program. PHP can do quite a bit of numerical manipulation and data processing.

                      CGI's are notoriously hard to debug because when something is not right, you get nothing other than the 500 error. If you are hell-bent on staying with CGI, then I would suggest opening up a log file and write messages to it as your program runs. That way you know if the thing is being run at all and what is happening inside your program.

                      I've never worked with IIS (thank goodness), but every web server I've ever used expected CGI's to output to standard out and to include (exactly) the headers that were mentioned previously. If you don't do that, then you get the 500 error. If I were you I would go on the web and look at other CGI examples (look on this forum too). I'm sure you could post a stripped-down version of your cgi program and you would get more specific help.



                      ------------------

                      Comment


                      • #12
                        Rui, if you are using IE, verify the option "Show friendly HTTP error messages"
                        in Properties / Advanced; if it's selected, try to unselect it and see
                        whether you get a more detailed error message than "500 internal server error".
                        In my experience, that error message is very generic and covers
                        a lot of things, included database access errors, and doesn't
                        necessarily indicate an internal error in the server sw.
                        By disabling "Friendly HTTP error messages" i get the SQL Server
                        or Oracle error message which was triggering the 500.

                        ------------------
                        Davide Vecchi
                        [email protected]

                        Comment


                        • #13
                          Dear friend,

                          I've tryed to disable the option in IE but it stills gives the same output error - with show friendly...

                          Can you check the url for me? It's:
                          http://novomilenio.lusoservers.com/c...hem/sephem.exe

                          Best regards,

                          ------------------
                          Kepler
                          Kepler

                          Comment


                          • #14
                            I tried the URL right now; i got a page showing only the message
                            "The specified path is invalid."

                            ------------------
                            Davide Vecchi
                            [email protected]

                            Comment


                            • #15
                              I've never worked with IIS (thank goodness)...
                              But Rui is working with it (check it at http://www.dnsstuff.com/tools/http.c...usoservers.com )
                              I agree that I²S is a bad choice for a webserver (too much complicated for a first try).

                              I don't recommend PHP either since this is a whole new programming environment to learn.
                              However, the commands are present inside the HTML, making it easy to debug --it's like javascript, but running on the server instead of the client machine).
                              The error mentioned above is caused by the server not finding the script to execute.

                              I'm programming with CGI for some years now (writing a complete Point-Of-Sales application, some search & indexing routines and a complete ordering system, all using standard CGI).
                              It's realy easy once you have the right mindset, only the first try-outs were daring.


                              ------------------
                              mailto:[email protected][email protected]</A> www.verfaillie.com www.idemdito.org

                              [This message has been edited by Marc Doigny (edited September 30, 2003).]
                              [email protected] | Zeepreventorium De Haan | Portraitfotografie | Home server

                              Comment


                              • #16
                                Testing shows that the PB/DOS version fails, but an equivalent PB/CC
                                version works fine. It seems the web server doesn't expect to run DOS
                                programs. You might investigate PB/CC, the PowerBASIC Console Compiler.

                                ------------------
                                Tom Hanlin
                                PowerBASIC Staff

                                Comment

                                Working...
                                X