Execute appliction and pass parameters to it!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  
Hi,

I am trying to execute one application (bat file) and need to pass parameter to it. I want to put this into wrapper file which i can call over http. Can i do this?

I tried the following:

------------------------------------------------------------------

1)  $output = shell_exec('..\phpunit.bat  C:\Run.php');
    echo $output;

Result: No output. Nothing happened.

2)  $cmd = '..\..\phpunit.bat';

// Setup an array of arguments to be sent.
$arg[] = "..\..\Run.php";

// Pick a place for the temp_file to be placed.
$outputfile = '..\..\CMDOUT.txt';

// Setup the command to run from "run"
$cmdline = "cmd /C $cmd " . implode(' ', $arg) ;

try
{
	echo "Came in try";
	$WshShell = new COM("WScript.Shell");  
	$oExec = $WshShell->Run($cmdline, 3, true);

	echo $oExec; // This is not getting printed.
	echo "Coming out of try";
}
 catch(Exception $e)
    {
		echo "came in catch";
        print("Caught Exception in " .
            $e->file() . " on line " .
            $e->line() . "<br>\n");
	}
Result: Nothing is happening. It is printing both the statements in the try block.

3) $firstArg = "C:\\..\\..\\Run.php";
$output = exec("C:\\..\\..\\phpunit.bat  $firstArg"); 

Result: Still nothing is happening.

4)$output = exec("C:\\..\\..\\phpunit.bat  $firstArg 2>&1", $myOut);
echo "<br/>My out value is ".$myOut;
Result: My out value is Array operable program or batch file.

--------------------------------------------------------------

All the above approaches not working for me.
Can somebody inform me where i need to make changes.
Thanks in advance.
Regards,

Dipesh


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux