• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

*RESOLVED* MSDOS *.EXE execution in a CGI-BIN *RESOLVED*

kevinthenerd

Platinum Member
I have a console application written as a DOS EXE file. It requires no user input; it just outputs text based on inputs that it gathers elsewhere. Is there a quick and easy way to have this file run as a web-based script so that I can call the program online and see its output in a web browser?

Cliff Notes: Basically, I want to use a DOS EXE file as a CGI script.
 
Is it C/C++ and you have source?

Compile it as a C++ Console app using Visual Studio. You can run these directly in IIS if you put them in a folder with excution allowed for both scripts and exe

< a href=" h ttp : // www.server.com / folder/file.exe > run me now! < / a >
 
I don't believe I have IIS on this machine.

How can I do this with Apache for Windows? (I'm more than willing to accept less-than-perfect security, which is what you'll get with Apache under Windows.)
 
Originally posted by: kevinthenerd
Originally posted by: DaveSimmons
Is it C/C++ and you have source?

You're gonna laugh. It's in QuickBASIC. VB doesn't handle console apps.
VB6 does if you use CGI4VB and compile to an exe.

I assume Apache should be able to run an .exe under Windows, but you'll need to Google to find out what to tweak if it isn't set to by default.
 
Originally posted by: DaveSimmons
Originally posted by: kevinthenerd
Originally posted by: DaveSimmons
Is it C/C++ and you have source?

You're gonna laugh. It's in QuickBASIC. VB doesn't handle console apps.
VB6 does if you use CGI4VB and compile to an exe.

I assume Apache should be able to run an .exe under Windows, but you'll need to Google to find out what to tweak if it isn't set to by default.

My installation of Apache isn't even running the perl script that's supposed to output your environment variables... never mind an EXE file designed for MSDOS.
 
This is really easy, don't let anyone tell you to do a million things combining Visual Basic and compiling new exes and such.

You say that your installation of apache wont run the perl test script it came with. Do you have perl installed?
You can test by opening up a command prompt and typing "perl -v". If it says "This is perl, v.5.8.x..." then it's installed. If it says "bad command or file name", then it's not installed. You can get perl for windows from Activestate.

Once you have your test perl script working, then you're going to create a new perl script. This will be the content of your new script:
#!C:\perl\bin\perl
print "Content-Type: text/html\n\n";
print `C:\path\to\my\file.exe`;

That's all. "C:\perl\bin\perl" should be the path to the perl executable that you installed. "C:\path\to\my\file.exe" should be the path to your quickbasic exe.

Now, save the perl script as something like "myfile.pl" and put it in your cgi-bin directory with your test script. Then go to your website, and run "myfile.pl". You'll see the output of your quickbasic program.
 
Originally posted by: notfred
This is really easy, don't let anyone tell you to do a million things combining Visual Basic and compiling new exes and such.

You say that your installation of apache wont run the perl test script it came with. Do you have perl installed?
You can test by opening up a command prompt and typing "perl -v". If it says "This is perl, v.5.8.x..." then it's installed. If it says "bad command or file name", then it's not installed. You can get perl for windows from Activestate.

Once you have your test perl script working, then you're going to create a new perl script. This will be the content of your new script:
#!C:\perl\bin\perl
print "Content-Type: text/html\n\n";
print `C:\path\to\my\file.exe`;

That's all. "C:\perl\bin\perl" should be the path to the perl executable that you installed. "C:\path\to\my\file.exe" should be the path to your quickbasic exe.

Now, save the perl script as something like "myfile.pl" and put it in your cgi-bin directory with your test script. Then go to your website, and run "myfile.pl". You'll see the output of your quickbasic program.

I somehow remember doing something similar with PHP back when I wanted my RedHat installation of Apache to provide the output of a Linux command. I'll try this. Thanks.
 
Do you have any ideas why it's just popping up the window briefly without actually outputting anything to the script? I think it's executing, but somehow the perl isn't getting its output. (I tried this both with an EXE made with QuickBASIC and an EXE made with Bloodshed DevC++.)
 
What do you mean "popping up the window briefly"? It's a webpage, it should be running in a browser, and the script I gave you certainly doesn't create any pop-up windows.
 
It was executing the program in a DOS window instead of outputting to the script directly. I fixed the problem my reversing the slashes. (Apparently it wants UNIX-style slashes in the path.)
 
Originally posted by: kevinthenerd
It was executing the program in a DOS window instead of outputting to the script directly. I fixed the problem my reversing the slashes. (Apparently it wants UNIX-style slashes in the path.)

Oops, yeah, the backslash is the escape character. You either need to double them up (C:\\whatever) or use forward slashes. My fault.
 
Back
Top