|
|
Subject:
Executing an a program on a server through a web browser
Category: Computers > Internet Asked by: belgiebob2-ga List Price: $5.00 |
Posted:
19 Jan 2004 19:10 PST
Expires: 18 Feb 2004 19:10 PST Question ID: 298232 |
I would like information including examples on how to execute a file on a server and give that file command line options via a fields entered into a webpage. Here is an example: field 1 field 2 field field 3 in are in a web page these fields contain command line options for schtasks.exe which is on the webserver how would I get that command (schtasks.exe) to run on the server with the command line options specified in the fields on the website when clicking the submit button on the form on the web page | |
| |
|
|
Subject:
Re: Executing an a program on a server through a web browser
Answered By: weaver-ga on 29 Jan 2004 12:46 PST Rated: |
PHP gives you functions to execute external commands from a script. The commands you'll find most useful are exec(), system(), and passthru(). The difference is that passthru and system will return all of the output from the command and exec won't. You can find more information on how to use these functions here: http://us4.php.net/manual/en/function.system.php http://us4.php.net/manual/en/function.passthru.php http://us4.php.net/manual/en/function.exec.php The setup you should use will have an HTML file with a form. The form will send data to the PHP script when it is submitted and the PHP script will execute the command passed to it. I have created examples of these files, this should get you going in the right direction: <!-- HTML Form --> <html> <body> <p><b>Command:</b> <form action="exec.php" method=post> <input type=text name=command maxlength=80> <input type=submit name=submit> </form> </p> </body> </html> <!-- End HTML --> <!-- Begin PHP script exec.php --> <html> <body> <?php if ((isset ($_POST['command'])) && (!empty ($_POST['command']))) { system ($_POST['command']); } else { print "No command given"; } ?> </body> </html> <!-- End PHP script exec.php --> These files were tested on a Linux/apache setup, but they should work in your environment as well. You may need to include the full path to the executable. You can add more command fields to the form or you can just put the full command line in the single textbox. Search strategy All relevant data was found by searching the function list on php.net. Good luck! Weaver |
belgiebob2-ga
rated this answer:
Thanks |
|
Subject:
Re: Executing an a program on a server through a web browser
From: weaver-ga on 30 Jan 2004 07:33 PST |
I'm glad you found my answer helpful. Thanks for the four star rating! Weaver |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |