| View previous topic :: View next topic |
| Author |
Message |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Fri Apr 30, 2004 11:54 am Post subject: CGI question |
|
|
I have obtained a CGI script written in PHP and I would like to create an EXE with similar functionality. The script is called with a line like this:
/cgi-bin/blah.php?op=1
I can't find how to obtain the value of this option from my EXE. It isn't on the command line, nor is it part of the data received through standard input. _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Fri Apr 30, 2004 12:52 pm Post subject: |
|
|
I knew you guys would have the answer. Thanks a lot!  _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Tue Jun 29, 2004 12:46 pm Post subject: |
|
|
Is there some way to read the standard input without using VDSSTDIO? It ought to be possible to do it using API calls, but knowing what a pain it can be to test API calls, I thought I'd ask in case someone had already done it. _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Tue Jun 29, 2004 2:36 pm Post subject: |
|
|
Hmm. I can't even get it to work using a DLL. Is it possible to do CGI using VDS 5?
The examples just do "console write". This just causes an I/O error. To see the output, you have to start with a "console open". But this causes the output to appear in a new console window, which is not what the web server is expecting. _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Tue Jun 29, 2004 3:42 pm Post subject: |
|
|
Only way I've ever been able to work in the cgi with a vds exe is through
the use of the vdsstdio.dll
Not sure about api's, but with the dll it's always been reliable for me. I
once was running a hosting service with 100 clients, all of which were
running off of vds cgi apps. And a few of those sites had a large traffic
flow and I don't remember vds ever failing under the high traffic
conditions.
Jules, if you need some more indepth help with this subject, contact me
via email garrett#vdsworld.com and I'll help you get your cgi stuff all
worked out. _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Tue Jun 29, 2004 5:45 pm Post subject: |
|
|
Garrett,
Were you using VDS 5 to compile these VDS CGI apps? My researches seem to show that the problem is that the VDS 5 compiler marks the EXEs as to run under the Win32 GUI subsystem. Under XP, anyway, this means that they don't get allocated a console. VB apparently has exactly the same problem, but its linker has an option to tell it to create a console app, as does Delphi of course. VDS doesn't. Therefore I really need to know what the conditions were that allowed this to work.
With VDS 5, I found that whether I used vdsstdio or any other method, I still got a runtime error when you try to read or write to the console, because the app doesn't have one.
If I altered a word in the EXE header, to say that it needs the CUI (character user interface) then the CGI examples worked.
I can't see what the situation was under VDS 4 because I don't have any VDS 4 EXEs to look at. I really need to determine whether there is a problem that ought to be fixed in VDS 5, or whether I was doing something wrong. _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Tue Jun 29, 2004 5:50 pm Post subject: |
|
|
I have used VDS 5 programs as console programs on my own webserver using the vdsstdio.dll. I even once managed to use this DLL to setup a VDS exe as an interpreter for ".vds" files, just like PHP can handle ".php" files, so I'm sure it most be possible...  _________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Tue Jun 29, 2004 5:58 pm Post subject: |
|
|
Interesting. The version of VDSSTDIO I have isn't the same as the one on this site. It doesn't have the CONSOLE CGI command. That one requires a registration code, which I don't have at the moment. _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Tue Jun 29, 2004 6:39 pm Post subject: |
|
|
No, I haven't tried cgi with VDS 5 yet myself. Yes, the vdsstdio.dll has
been updated within the last few years, so give that a try. _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Tue Jun 29, 2004 7:23 pm Post subject: |
|
|
It doesn't seem to make a difference. Sorry to go on about this but I'm really puzzled.
The cgi program created using vdsstdio has to start with console open. If you run this program form a command prompt under XP, this command creates a separate console window, and the output appears in there. A program like that does not work with the web server.
I have a test CGI program written in Delphi. This is compiled as a console application. If I run it from a command prompt the output appears in the same console window as the command prompt. This program works with the web server.
If I change the EXE header of the VDS program, after compiling it without the console open command, the output appears in the same console window as the command prompt, just like my Delphi example. This program also works with the web server.
Therefore it seems to me that for a CGI program to work, the input and output must use the same window as the command prompt. The web server is not able to work with it if it uses a separate console window.
What I need to know is, if you run one of your CGI EXEs from a command prompt, does it create a separate console window? If it does, then perhaps it's a limitation of some web servers that they can't use programs that use a different window. Perhaps it has something to do with the way the CGI process is created? If the output appears in the same window, then I'm stumped, because I tried umpteen different ways to try to get the output to use the same console window, and I could only get it to work after modifying the VDS EXE header. _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Wed Jun 30, 2004 2:37 am Post subject: |
|
|
Ok, here's what I remember about the CONSOLE CGI line....
On IIS, a vds exe as a cgi app will not work without the CONSOLE CGI line,
but Apache won't work with that line. So on Apache, REM out the line.
Now of course, this was not using VDS 5. I just installed a few servers here
and am testing VDS 5 in the cgi now. So far, no problems for me. But I
am not running on a NT system here, I'm running on ME at the moment.
Here's a short example to try on your end:
| Code: | OPTION Errortrap,Error
TITLE CGI VDS/EXE Test
EXTERNAL @path(%0)vdsstdio.dll,Your Info Here
#DEFINE COMMAND,CONSOLE
#DEFINE FUNCTION,CONSOLE
CONSOLE CGI
Console write, Content-type: text/html@chr(10)
Console write, @chr(10)
Console write, At the tone, the time will be: @datetime(TT)@chr(10)
Console write, @chr(10)
Exit
:Error
%%CurDate = @datetime(ddddd)
%%CurTime = @datetime(tt)
%%RemoteAddr = @env(REMOTE_ADDR)
%%Referer = @env(HTTP_REFERER)
%%Agent = @env(HTTP_USER_AGENT)
%%QueryString = @env(QUERY_STRING)
List Create,9
List Loadfile,9,@path(%0)dat\error.log
List Add,9,%%CurDate|%%CurTime|Error Code: @error(E)|Error Line: @error(N)|%%RemoteAddr|%%Referer|%%Agent|%%QueryString
List Savefile,9,@path(%0)dat\error.log
Exit |
_________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Wed Jun 30, 2004 8:21 am Post subject: |
|
|
Here's the script I'm using:
| Code: | option errortrap,Error
external @path(%0)vdsstdio.dll,Your Info Here
#define command,Console
#define function,Console
Console CGI
rem @env(QUERY_STRING)
rem @env(HTTP_REFERER)
rem @env(REMOTE_ADDR)
rem @env(HTTP_USER_AGENT)
Console write, Content-type: text/html@chr(10)
Console write, @chr(10)
Console write, <table border='1' align='right'><tr><td><font face='Courier New'><small><b>Files</b><p>@chr(10)
list create,1,sorted
list filelist,1,C:\Website
%z = 0
repeat
Console write,<a href='/@name(@lower(@item(1,%z))).@ext(@lower(@item(1,%z)))'>@name(@lower(@item(1,%z))).@ext(@lower(@item(1,%z)))</a><br>@chr(10)
%z = @succ(%z)
until @equal(%z,@count(1))
list close,1
Console write,</small></td></tr></table></small></font><p>@chr(10)
Console write, <font face='Verdana'><small>Hello<p>@chr(10)
Console write, You tried to access this page with this query: @env(QUERY_STRING)<p></small></font>@chr(10)
Console write, <font face='Verdana'><small>The current server time: <b>@datetime(dddd d mmmm yyyy h:nn:ss)</b></small></font><p>@chr(10)
dfg
exit
:Error
Console write, <p><hr size='1'>@chr(10)
Console write, <font color='red' face='Verdana'><small><b><center>An error has occured. Please contact the webmaster.</center></b></small></font>@chr(10)
Console write, <hr size='1'><p>@chr(10)
exit |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|