EXE CGI file

 
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI
View previous topic :: View next topic  
Author Message
b123
-


Joined: 12 Oct 2004
Posts: 9

PostPosted: Tue Oct 12, 2004 1:09 am    Post subject: EXE CGI file Reply with quote

How do I use an EXE as a CGI? Do I need to configure anything?
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Tue Oct 12, 2004 3:25 am    Post subject: Reply with quote

No , EXE files are already setup as a seperate application.

Warning! running .exe files on the server can be dangerous
Back to top View user's profile Send private message Visit poster's website
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1295

PostPosted: Tue Oct 12, 2004 12:12 pm    Post subject: Re: EXE CGI file Reply with quote

b123 wrote:
How do I use an EXE as a CGI? Do I need to configure anything?

Yes, you can use it. But you'll have to add it virtual path to the CGI Paths. For example, if your CGI application is in http://yoursite/dir1/dir2/cgiapp.exe , add /dir1/dir2/cgiapp.exe to the CGI Paths. If you have a lot of CGI apps in the same dir, you can use patterns and add /dir1/dir2/*.exe (but be careful when using patterns, a wrong setting can make other .exe run on the server instead of being downloaded.)
Back to top View user's profile Send private message
b0b
-


Joined: 01 Jun 2004
Posts: 24

PostPosted: Sat Nov 06, 2004 1:22 am    Post subject: Re: EXE CGI file Reply with quote

b123 wrote:
How do I use an EXE as a CGI? Do I need to configure anything?

Write your app in C or C++.
Make sure you stdout "Content-type: text/html\n" before the rest of your code, then compile with:
Code:
gcc -o <source w/o extension>.cgi <source w/ extension>

ex. gcc -o Hello.cgi Hello.c
Then make sure the file is in your /cgi-bin/ alias
Back to top View user's profile Send private message
Quadro
-


Joined: 18 Dec 2003
Posts: 6
Location: New Jersey, USA

PostPosted: Sat Dec 25, 2004 8:18 am    Post subject: Reply with quote

Quote:
Write your app in C or C++.

You can use any language you want to write your CGI EXE, though I would suggest C. I've successfully written a CGI EXE in assembly before, but I don't recommend it! (That was actually before I learned C, and I could rewrite it as a C program much more easily)

Also, just to see whether I could, I made a CGI script in Java. Let me tell you, it was NOT fun to get the server to run it properly!

Here's a quick CGI in C (as a test only - I haven't compiled it but it should work):
Code:
#include <stdio.h>

int main(int argc, char *argv[]) {

puts("Content-type: text/html\n");
puts("<html><head><title>CGI-EXE test</title></head><body>After compiling with your favorite compiler, this program can test your server's options to make sure CGI-EXE scripts work</body></html>");
return 0;

}


Since allowing EXE files to run on your server can be dangerous, I would suggest only using those that you wrote yourself (or those that you compiled yourself after thoroughly reading the source) so that you know what they do.
Back to top View user's profile Send private message
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Sun Jan 21, 2007 2:34 pm    Post subject: Reply with quote

You'll need two new lines after the header.

Code:
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  puts("HTTP/1.1 200 OK\nContent-type: text/plain\n\nHello world!");
  return 0;
}


I was able to compile this code using Dev-C++ and run it as a CGI application in Abyss.
Back to top View user's profile Send private message
kukiz
-


Joined: 07 Apr 2006
Posts: 6

PostPosted: Wed Mar 07, 2007 2:23 am    Post subject: CGI in D on Linux Reply with quote

If somebody used DigitalMars D language for CGI application :?:
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Wed Mar 07, 2007 5:23 pm    Post subject: Re: CGI in D on Linux Reply with quote

kukiz,

We have not tested it but there is no reason why it wouldn't work.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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


Powered by phpBB phpBB Group