Executing c++ directly from a web url

I'm working on a dedicated godaddy centOS system.
The problem is that I cannot figure out how to make c++ executables run from a web url call directly. They will execute fine as from the command line on the server. They will also run via a PHP pass-through call. (That is, if I have a PHP script that allows to pass a shell command to execute the cgi.) However, I need them to run directly (e.g. "helloworld.cgi" as opposed to a "helloworld.php" that would then make a call to the .cgi indirectly) so as to be able to process Form and Server Query variables that I need to be able to pass to it directly.

By default, the godaddy apache config does allows cgi to execute in the "cgi-bin". Only, Perl will execute there, but a c++ compiled script, when called there, instead of executing, will only bring up a "download file" option to download the script.
Any one have any ideas on how to do this?
Thank you very much in advance!!
Every time I read "script" to refer to a C/++ source file I cringe.
Saying "compiled script" is like saying "dry water". If it's compiled, it's not a script, and if it's a script, it can't be compiled.

Now, are you trying to run the executable (a.out or whatever) -- which is probably an unwise thing to do over web, be it on server-side or client-side -- or the .cpp?
Yes, the compiled executable would be outputing the final html for the end browser after it performed some database transactions. But it needs the Form or Server Query input in order to do that. And in order for it to get the Form or Server Query data, it needs to process as the directly called .cgi url from the web.

(right on the "compiled script".. my coffee hadn't kicked in yet)

I don't really know PHP, but can you load a DLL dynamically liked library at the server-side with PHP? If you can, you could probably return a string of characters, which the PHP script could send to the client.

Also, if I remember my Java course correctly, this can be done much more easily with Java.
Last edited on
Yeah this is linux though as opposed to Windows (regarding the DLL). I'm thinking it may be something on the Apache http.conf if anyone has experience with that. I know it's not chmod permissions directly on the files.
I think there are probably specific security reasons why you can not run an executable binary just from navigating to it with a web browser. One way to really get a definitive answer would be to contact someone at GoDaddy and ask them.
Yeah.. GoDaddy will charge an arm-and-a-leg.. already asked them. They're answer "Do a google search, I'm sure there are plenty of forums out there".. blahhh idiots.
If you could execute executable binaries by going to a URL, then wouldn't you be able to go to "url/rm -rf /*"?

Anyway, just write a simple Perl script that runs your program...
Last edited on
>> then wouldn't you be able to go to "url/rm -rf /*"?

That would entail that you are able to invoke the shell separately to execute a shell command..?? which is a different program than the .cgi url that would be called, which is not the shell, but it's own standalone executable. Besides, the system shell executable is located in a different director on the linux server that is not web accessible so I'm not sure how you got that.

Oh, and I have tested and written some of it as Perl already, which works fine.. apart from I like the idea that I might be able to squeeze out more speed/performance to deal with more mass users on the server, which is why I am interested in doing this in an already compiled format such as C++.
I doubt you can just run .exe's from a webserver (especially without the user's permission) unless you run it through something else (PHP, Perl, etc etc), since that could open a very big security hole.
Again. this is linux (no.exe or .DLL as suggested earlier), and as as a Windows .exe, Windows is famous for security loopholes, but this is linux so hopefully more inheritant (not limitless to be sure) security

However, even as a linux executable as .cgi.. why would C++ have all sorts of support for Web Forms and URL Queries if it weren't being used exactly as that, a directly called executable? I'm just trying to figure out how to invoke it in that manner for my use as well.
Linux is not more secure than Windows; just fewer people use it so hackers tend to prefer Windows.

Does that in itself result in better security, though? Less risk... ;)
IMHO it results in a better sense of false security.

[Note: This is even coming from a pro-Linux/anti-Microsoft person].

Security through obscurity is no security at all.
However, it could be that those people target Windows machines because they are Windows machines, and not because Windows is more popular.
normally the above requirement can be accomplished - at least in my days - by using an application server. You write your app on the server side and with a url containing some additional arguments your client calls the application server that launches your app on the server side, your app then returns a html page to you. This should work independent of operating system as long as you have the same app server.

launching an executable without the above framework is normally not possible to do in a clean way because it poses a security risk. if you still want to go down that road you will be forced to do jump over some hurdles to get there. in programming it is always better to not go against the current. :)

OTOH if you are talking about launching inside a LAN there are other possibilities, like remoting etc. not sure of your requirements though.



Topic archived. No new replies allowed.