tags:

views:

203

answers:

2

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("cmd /c D:\\workspace\\execute.bat");
?>
</body>
</html>

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

A: 

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.

Sarfraz
+1  A: 

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.

Felix Kling