Author Topic: Oxygen executables as cgi scripts.  (Read 2551 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Guest
Oxygen executables as cgi scripts.
« on: August 11, 2019, 11:51:45 PM »

 Hello Charles, i was wondering if you have tried to use Oxygen executables as web scrips (cgi)?

 I currently am testing the database features and I would like to test them in a web server, but no
matter what i do, the server rejects oxygen executables as cgi scripts (standard out)...

Brian Alvarez

  • Guest
Re: Oxygen executables as cgi scripts.
« Reply #1 on: August 12, 2019, 12:02:46 AM »
AFAIK these two scripts are outputting the same standard out:

Code: [Select]
http://www.nbson.com/test/pb_test.exe
http://www.nbson.com/test/ox_test.exe

 They both show the exact same HTTP headers, but for some reason the server rejects the oxygen one.

 Im attaching the executables in case someone wants to analyze them.
These give slightly different headers, but both should be valid.

 I am guessing i need to manually edit some bits in the exe header...

Mike Lobanovsky

  • Guest
Re: Oxygen executables as cgi scripts.
« Reply #2 on: August 12, 2019, 12:33:22 AM »
There you have a GUI application without icon, manifest or version that has kernel calls, accesses the registry, and has been compiled with an unknown compiler... ::)

If I were in that server's shoes, I would surely never let you through the front door, Brian. ;D

Brian Alvarez

  • Guest
Re: Oxygen executables as cgi scripts.
« Reply #3 on: August 12, 2019, 08:56:52 AM »
 I doubt it is because of that Mike. PowerBASIC's executables work fine with no manifest or app icon.
im sure it is something very simple.

Brian Alvarez

  • Guest
Re: Oxygen executables as cgi scripts.
« Reply #4 on: August 12, 2019, 10:27:10 AM »
Quote
https://www.ietf.org/rfc/rfc3875

Quote
https://www.devside.net/wamp-server/running-exe-and-batch-files-as-cgi-scripts-in-apache-under-windows

Quote
3.4.  Execution

   The script is invoked in a system-defined manner.  Unless specified
   otherwise, the file containing the script will be invoked as an
   executable program.  The server prepares the CGI request as described
   in section 4; this comprises the request meta-variables (immediately
   available to the script on execution) and request message data.  The
   request data need not be immediately available to the script; the
   script can be executed before all this data has been received by the
   server from the client.  The response from the script is returned to
   the server as described in sections 5 and 6.

   In the event of an error condition, the server can interrupt or
   terminate script execution at any time and without warning.  That
   could occur, for example, in the event of a transport failure between
   the server and the client; so the script SHOULD be prepared to handle
   abnormal termination.

 I think the server is terminating the executable for some reason before it gets
the chance to output anything.
« Last Edit: August 12, 2019, 11:08:46 AM by Brian Alvarez »

Mike Lobanovsky

  • Guest
Re: Oxygen executables as cgi scripts.
« Reply #5 on: August 12, 2019, 02:13:52 PM »
Brian,

Would you care to upload a matching PowerBASIC executable that you claim to be working for you on this server?

Brian Alvarez

  • Guest
Re: Oxygen executables as cgi scripts.
« Reply #6 on: August 12, 2019, 02:28:06 PM »
 You mean on the Oxygen's server? Sure.  I assume you mean that, because i already posted the executables in this thread.

 But hold on... maybe i have tackled it.

Brian Alvarez

  • Guest
Re: Oxygen executables as cgi scripts.
« Reply #7 on: August 12, 2019, 03:25:52 PM »
 I got it!  ;D

Quote
http://www.nbson.com/test/oxcgi.exe

It was something else after all. Now i can finish my database support.

Added:
CGI in 64 bits works fine too. :)
Quote
http://www.nbson.com/test/oxcgi64.exe

 It is very satisfactory working with it. :)
« Last Edit: August 12, 2019, 04:35:44 PM by Brian Alvarez »

Mike Lobanovsky

  • Guest
Re: Oxygen executables as cgi scripts.
« Reply #8 on: August 12, 2019, 05:38:25 PM »
I got it!  ;D ... It was something else after all.

Something's telling me you probably got it to try and compile your executable (or brute-force it in a hex editor) to be a genuine console, rather than GUI, program. ;D

Brian Alvarez

  • Guest
Re: Oxygen executables as cgi scripts.
« Reply #9 on: August 12, 2019, 06:57:14 PM »
  I wanted to, but there was no need. I read about #console.  :)
Plus other things i found. It wasnt simple.

 The thing was that i was working in 64 bit mode, but in 64 bit mode
one oxygen statement was appending an extra CRLF, so i made my
own cgi class and enhanced STDOUT to work with it. Now STDOUT will
output the headers automatically on the first call  if they haven't been
sent (just like php) and then output the desired string.

 Now i just need to setup a database and start my tests. But it all looks
very good.

 
« Last Edit: August 12, 2019, 07:10:19 PM by Brian Alvarez »

Mike Lobanovsky

  • Guest
Re: Oxygen executables as cgi scripts.
« Reply #10 on: August 12, 2019, 11:19:04 PM »

Charles Pegge

  • Guest
Re: Oxygen executables as cgi scripts.
« Reply #11 on: August 13, 2019, 02:43:29 AM »
Hi Brian,
Is #console (setting PE file subsystem type 3) always necessary for cgi executables?

Brian Alvarez

  • Guest
Re: Oxygen executables as cgi scripts.
« Reply #12 on: August 13, 2019, 09:05:25 AM »
Hi Brian,
Is #console (setting PE file subsystem type 3) always necessary for cgi executables?

 No, it is not. It is what i used to chage the executable to console when nothing else was working.
A regular executable works fine for CGI.

The problem was that the 64bit version was inserting an extra CRLF... making me think it was not
working while only the headers were being sent wrong (the extra CRLF was indicating the end of
the headers) but i lost the code while trying stuff and now i cannot show the code...