开发者

Run a batch file using php

Below is my piece of code , on giving the tool name as the input and pressing submit , the batch file corresponding to that tool shall be executed.

<html> 
   <head> 
     <title>My Form</title> 
   </head> 
 <body> 
 <form action="batch.php" method=post> 

 Which tool you would like to use:
 <br> <input type="text" name="ToolName"> 
 <p> 
 <input type="submit" name="submit" value="Please wait!">
 </form>
 </body>
 </html>

BATCH.php

<html>
<head>
<title>Perv!</title>
</head>

<?php
$ToolName = $_REQUEST['ToolName'] ; 
?>
<p>
Hi <?php print $ToolName; 
//exec("cmd/c D:\workspace\execute.bat");
exec("C:\\wamp\\www\\test.bat");
//system("test.bat");
//system("cm开发者_StackOverflowd /c D:\\workspace\\execute.bat");
?>
</body>
</html>

I am using Apache /Windows. Please suggest any help will be appreciated.


As I already commented, what you describe seems to be a problem of your batch file. But anyway, is this file supposed to just do something or to output stuff that should be displayed?

If the later is the case, note that exec() only returns the last line of the output. You can get all the output be providing another variable to get all the output. The official php documentation of the exec() function tells you have to do this.


as far as i could understand your question, you can try this:

system($ToolName);

You may want to specify correct path for the $ToolName variable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜