I am trying to run a python script or a batch file to create a sample file and send it over the mail when I click a button in a HTML page.
Below is my batch file(on running it creates a new file with 'sample text' inside)
// **foo.bat**
echo sample text > MyFile.txt
As I am using JavaScript, I need the above batch file to run in the background on a button click. So I tried to use iframe like below but the contents of batch file got displayed rather than running.
<html>
<body>
<iframe id="iframeId" width="1" height="1"></iframe>
<input value="Run batch" onClick="RunBatch();"
</body>
<script>
function RunBatch(){
document.getElementById('iframeId').src="foo.bat";
}
</script>
</html>
I referred How to run .exe file or .bat file based on button click event using Javascript- duplicate thread but by using it, we should run as a HTA application which again behaves similar to a batch file.
Could anyone tell me a way to run the python script or a batch file in background on a HTML button click?