•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 391,667 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,927 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 869 | Replies: 2
![]() |
•
•
Join Date: Jan 2008
Posts: 1,403
Reputation:
Rep Power: 6
Solved Threads: 179
This is my first shot at running an executable program from a web page. The program is going to get a lot bigger, as will the web site. I have xampp installed and I am using that. I have two simple files:
C:\xampp\htdocs\execlink.html
and:
C:\HelloWorld.exe
The web page is:
http://127.0.0.1/execlink.html
Anyway, I click on the link within execlink.html that is supposed to run HelloWorld.exe and nothing happens. The program doesn't run, which I suppose is probably a good thing from a security standpoint since I still have basically the default configuration. I have heard that I need to rename the executable file with a ".cgi" extension from a ".exe" extension and stick it somewhere besides the root "C" directory and maybe mess with a configuration file or two. Any ideas? Thank you.
C:\xampp\htdocs\execlink.html
html Syntax (Toggle Plain Text)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html><head><title>Attempt to run an executable from a web page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <a href=file://C:/HelloWorld.exe>Run Hello World Executable</a> </body> </html>
and:
C:\HelloWorld.exe
C++ Syntax (Toggle Plain Text)
// Filename : HelloWorld.cpp // Executable Name : HelloWorld.exe #include <fstream> using namespace std; int main (int argc, char* argv[]) { ofstream outs; outs.open ("HelloWorld.txt"); outs << "Hello World" << endl; return 0; }
http://127.0.0.1/execlink.html
Anyway, I click on the link within execlink.html that is supposed to run HelloWorld.exe and nothing happens. The program doesn't run, which I suppose is probably a good thing from a security standpoint since I still have basically the default configuration. I have heard that I need to rename the executable file with a ".cgi" extension from a ".exe" extension and stick it somewhere besides the root "C" directory and maybe mess with a configuration file or two. Any ideas? Thank you.
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 936
Reputation:
Rep Power: 5
Solved Threads: 47
I'm not sure what configuration tricks you'll need to perform to get this to work on Windows + XAMPP, but, the following looks 'wrong':
- your href in the HTML goes to a local file, this certainly wont work. You'll need to move the compiled C++ application into the folder which XAMPP maps to 127.0.0.1, and change the link to href="http://127.0.0.1/HelloWorld.exe".
- It is possibly the case that the C++ app will have to go into the cgi-bin folder, I haven't used XAMPP for a long time, and cant remember how it deals with executables and permissions.. read the XAMPP docs if in doubt.
- The program will not work properly as a CGI script because it's not sending an HTTP header. Change to the following ( although the program should work [ as in write to the file ] if you set everything up properly, it will display an Error 500 if you do not make this change ):
Don't worry about security right now ( but certainly read up about it when you get the time ). XAMPP doesn't make your computer a public server with the default settings, and nobody but you can access 127.0.0.1 and see your files, if I go to 127.0.0.1 it will send me to any server program on my PC ( I don't have one running, but it would if I had Apache on ).
- your href in the HTML goes to a local file, this certainly wont work. You'll need to move the compiled C++ application into the folder which XAMPP maps to 127.0.0.1, and change the link to href="http://127.0.0.1/HelloWorld.exe".
- It is possibly the case that the C++ app will have to go into the cgi-bin folder, I haven't used XAMPP for a long time, and cant remember how it deals with executables and permissions.. read the XAMPP docs if in doubt.
- The program will not work properly as a CGI script because it's not sending an HTTP header. Change to the following ( although the program should work [ as in write to the file ] if you set everything up properly, it will display an Error 500 if you do not make this change ):
CPP Syntax (Toggle Plain Text)
// Filename : HelloWorld.cpp // Executable Name : HelloWorld.exe #include <fstream> #include <iostream> using namespace std; int main (int argc, char* argv[]) { cout << "Content-Type:text/html;charset=iso-8859-1\n\n"; ofstream outs; outs.open ("HelloWorld.txt"); outs << "Hello World" << endl; return 0; }
Don't worry about security right now ( but certainly read up about it when you get the time ). XAMPP doesn't make your computer a public server with the default settings, and nobody but you can access 127.0.0.1 and see your files, if I go to 127.0.0.1 it will send me to any server program on my PC ( I don't have one running, but it would if I had Apache on ).
If it only works in Internet Explorer; it doesn't work.
•
•
Join Date: Jan 2008
Posts: 1,403
Reputation:
Rep Power: 6
Solved Threads: 179
Thank you for replying. I've been fiddling around with it. It seems to be looking in the current directory (as opposed to the cgi-bin directory). It finds HelloWorld.exe now, but doesn't seem to realize I am trying to execute it and it offers to let me save it. Seems like it thinks it is a text file or something. I changed the link to a perl file that came with xampp. It displayed (but did not run) that program to the screen, but still looked for the one in the local directory. When I switched to a link with a .cgi suffix, it appears to have looked in the cgi-bin directory and actually ran it. It was set up to print information in html and it did that. However, it didn't print the word "print" but rather the contents inside the quotes, so I'm guessing that one worked correctly. It seems like the suffix of the file is important as far as xampp knowing what to do with it? There must be a list of file extensions somewhere where I need to specify that I want".exe" to run? Still experimenting around with this. Thank you.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb HTML and CSS Marketplace
•
•
•
•
adult advertising article blog browser browsers browsing community dani web data design development devices domain domains firefox forensic google help html internet legal linux marketing math michael knight microsoft mozilla multimedia navigation news opera php privacy registration report research revenue search security seo software survey video w3c web web development xml yahoo
- Google search pages dont link when clicked.error:( (Viruses, Spyware and other Nasties)
- Links not working in web sites using Internet Explorer 6.0 (Viruses, Spyware and other Nasties)
- Modem sound (Windows 9x / Me)
- Web Link freezes - Hijack This results (Viruses, Spyware and other Nasties)
- wupdater.exe error message (Web Browsers)
- Windows XP takes too long to start up (Windows NT / 2000 / XP / 2003)
Other Threads in the HTML and CSS Forum
- Previous Thread: Useing Image, Drop down
- Next Thread: General rules when working with divs and css.



Linear Mode