I have a compiled C++ program called “main”.
Instead of running the program from a terminal, I would like to click a button on a webpage to run it.
How would I go about doing this?
In this example, the browser downloads the program instead of running it.
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>title</title>
</head>
<body>
<form name="input" action="main" method="post">
<input type="submit" value="Run Program">
</form>
</body>
</html>
There is no way to do this without a web server running locally. Starting programs directly by clicking on web pages would lead to serious security problems.
If you are on Windows, and really want to start executables from HTML pages, then consider using an HTA (example).
== EDIT ==
I just realized that the example I mentioned above shows a way to start a program (notepad.exe) directly from the browser. Save this code as
test.html, open it in Internet Explorer, and click on the button:You will get a warning, but after clicking on “Yes”, Notepad will start.