I'm looking to find a way on how to start a .bat file from a webpage. This bat file just start a server.
My intention is to create a basic html page showing "Start server" and "Close Server".
Is there a way to do so? I was thinking to do it by an FTP server using HTML but it didn't helped me.
Thanks
With a static page would be difficult but for example using php :
<?php
exec('c:\myfile.bat');
?>
If you don´t want execute the .bat locally you will execute a shell script (.sh) that executes remotely the batch file.
https://superuser.com/questions/292818/run-a-shell-script-with-an-html-button
You need to call cgi script for this action with proper access to start your services. Html doesn't have any access in server side. It can only trigger the request.
Put 2 files in your web folder:
Static html showing your bottoms
A PHP file to call the batch.
Just remember to install PHP on your IIS
Related
I have a bat file and I can run this file as administrator by right click on it. Now I create a link which calls the bat file on html page. I want to hit the link and run the file as administrator.
The code which calls my file normal way.
Restart DirectDataLink
Adjust the script (Link) below the line ::START that needs to run elevated in below posted batch script. For your example: call service-restart.bat and save it as RunElevated.bat
Change your link to Restart DirectDataLink.
The RunElavated will call your batch script and will try to "selfelevate".
I hit the 404 error when I use the following the code in index.pl (I only create one perl app in my account)
my $hello_link = "$ENV{'OPENSHIFT_REPO_DIR'}hello.pl";
Click <font color="FF00CC">here</font> to run hello world cgi.</br>
When I log to my web autortl-rdlgen.rhcloud.com and click on ¨Here"to run hello program. The error message showed
Not Found
The requested URL /var/lib/openshift/550f4df1fcf933b971000030/app-root/runtime/repo/hello.pl was not found on this server.
I do have uploaded hello.pl to my repo directory and can find it after SSH to my account:
[autortl-rdlgen.rhcloud.com repo]\> ls -tr hello.pl
hello.pl
You need to use a relative link like this "./hello.pl" instead of using the other link with the ENV variable, which is showing the complete filesystem path to your perl file.
You may want to check out some Perl tutorials to help you get started with your Perl web programming: http://www.tutorialspoint.com/perl/perl_cgi.htm
I have added my webpage contents to /var/lib/openshift/XXXXXXXXXXXXXXXXXXXXX/app-root/runtime/dependencies/jbossews/webapps/ directory and I can see my webpage.
I have not used git repository.
I tried adding one shell script under /var/lib/openshift/XXXXXXXXXXXXXXXXXXXXX/app-root/runtime/repo/.openshift/cron/hourly directly. I dont see the script running.
I feel it has to be pushed to some service. Can this be done without git at all?
Adding example:
I have not created a git repository.
I have a index.html with just some header and body placed under /var/lib/openshift/XXXXXXXXXXXXXXXXXXXXX/app-root/runtime/dependencies/jbossews/webapps/test/.
Now I can access the website like www.test-rhtest.rhcloud.com/test/index.html
Now I have a shell script say test.sh. It is as below.
#!/bin/bash
echo date >> $HOME/app-deployments/temp.txt
I execute the script test.sh and it creates the file there $HOME/app-deployments/temp.txt.
Now I have placed the file under /var/lib/openshift/XXXXXXXXXXXXXXXXXXXXX/app-root/runtime/repo/.openshift/cron/hourly. I waited for hours to see execution, but no luck.
How should I enable this cron now?
The file SHOULD run, but you have to make sure that you made it executable (chmod +x) on the server. Also, make sure you can run it manually without getting any errors. Also, it seems you should put it into your ~/app-root/repo/... directory, instead of the runtime one.
I have an OpenShift server running python. However when I call php via SSL the php interpreter starts running. It suggests that there might be a way to run php as well. However, HTML if fair enough for me. Now, I do not know how to be able to reach html files on my server as when I am trying I always get 404 not found. I've read about a solution of placing a .htaccess file:
AddType application/x-httpd-php .html
I am not exactly sure where to place this file but placing in the folder of the .html file still not helps.
Could you please help me how I can make .html files reachable at an OpenShift server running Python? How about php?
Put the .html file in your app-root/repo/wsgi/static folder (or in that folder in your git repository). if you want it to be displayed like app-domain.rhcloud.com/file.html, you will have to use a .htaccess file in your wsgi folder that rewrites file.html to static/file.html
When I submit my basic form from the html file, it gives me the option to save the exe
I just want the exe to run instead. (To re-populate the template html file)
What do I need to do to just run the exe once the form is submitted?
<form action="Lib.exe" method=POST ID="Form1">
Enter Index to DELETE<br>
<input type=text name="user" ID="Text1">
<input type=submit value="DELETE">
</form>
I am running a web server. The html file and the .exe are in the directory to run web files.
Any help is appreciated.
Thanks.
I assume the lib.exe does its template updating on the server, meaning you need to configure your web server to run exe files instead of serving them to the user. You do not specify the server you run (somehow I assume you run IIS...), but in Apache you would use <FilesMatch> in httpd.conf to add a handler for exe, something like this:
<FilesMatch \.cgi$>
SetHandler cgi-script
</FilesMatch>
but adapted to exes. See mod_mime documentation here.
Please clarify your question. What are the OS and the web-server, does web server run with restricted permissions?
Can you port Lib.exe into the language used by your web-site (PHP or ASP or whatever)?
Executing server side scripts as CGI for small tasks can slow down the system as the OS needs to start a new process, allocate resources for the new process, etc... Compiled C++ can be slower than PHP interpreted by loaded module.
Figured it out. I didn't have the content type in the CGI app.
" Content-type: text/html"
Without this the web server won't execute it. Newbie error. Thanks guys.
Now my html file runs on the web server, the form calls the exe in the cgi-bin directory and executes the deletion, specified by the user.
My next challenge is figuring out how to not actually display or go to the Lib.exe in the browser. I want it to run as it's doing, but stay at my html page as it is now updated. i don't want to have to manually go back to my html page.
You can use AJAX instead of form submitting and achieve the same result.