| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		b123 -
 
  Joined: 12 Oct 2004 Posts: 9
 
  | 
		
			
				 Posted: Tue Oct 12, 2004 1:09 am    Post subject: EXE CGI file | 
				      | 
			 
			
				
  | 
			 
			
				| How do I use an EXE as a CGI? Do I need to configure anything? | 
			 
		  | 
	
	
		| Back to top | 
		
			          | 
		
	
	
		  | 
	
	
		TRUSTAbyss -
 
  Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
  | 
		
			
				 Posted: Tue Oct 12, 2004 3:25 am    Post subject:  | 
				      | 
			 
			
				
  | 
			 
			
				No , EXE files are already setup as a seperate application.
 
 
Warning! running .exe files on the server can be dangerous | 
			 
		  | 
	
	
		| Back to top | 
		
			           | 
		
	
	
		  | 
	
	
		admin Site Admin
 
  Joined: 03 Mar 2002 Posts: 1348
 
  | 
		
			
				 Posted: Tue Oct 12, 2004 12:12 pm    Post subject: Re: EXE CGI file | 
				      | 
			 
			
				
  | 
			 
			
				 	  | 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 | 
		
			          | 
		
	
	
		  | 
	
	
		b0b -
 
  Joined: 01 Jun 2004 Posts: 24
 
  | 
		
			
				 Posted: Sat Nov 06, 2004 1:22 am    Post subject: Re: EXE CGI file | 
				      | 
			 
			
				
  | 
			 
			
				 	  | 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 | 
		
			          | 
		
	
	
		  | 
	
	
		Quadro -
 
  Joined: 18 Dec 2003 Posts: 6 Location: New Jersey, USA
  | 
		
			
				 Posted: Sat Dec 25, 2004 8:18 am    Post subject:  | 
				      | 
			 
			
				
  | 
			 
			
				 	  | 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 | 
		
			          | 
		
	
	
		  | 
	
	
		cmxflash -
 
  Joined: 11 Dec 2004 Posts: 872
 
  | 
		
			
				 Posted: Sun Jan 21, 2007 2:34 pm    Post subject:  | 
				      | 
			 
			
				
  | 
			 
			
				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 | 
		
			          | 
		
	
	
		  | 
	
	
		kukiz -
 
  Joined: 07 Apr 2006 Posts: 6
 
  | 
		
			
				 Posted: Wed Mar 07, 2007 2:23 am    Post subject: CGI in D on Linux | 
				      | 
			 
			
				
  | 
			 
			
				| If somebody used DigitalMars D language for CGI application  :?: | 
			 
		  | 
	
	
		| Back to top | 
		
			          | 
		
	
	
		  | 
	
	
		aprelium -
 
  Joined: 22 Mar 2002 Posts: 6800
 
  | 
		
			
				 Posted: Wed Mar 07, 2007 5:23 pm    Post subject: Re: CGI in D on Linux | 
				      | 
			 
			
				
  | 
			 
			
				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 | 
		
			           | 
		
	
	
		  | 
	
	
		 |