I have a java file and it will generate a report. I want to execute this within in a php script. Im using the exec() function in php:
<?php
$output = array();
$return = 0;
exec("D:");
exec("cd class");
exec("java login username password id name Daily Detailed 20120820",$output,$return);
?>
When I execute this commands in windows command prompt it works properly. But not in a php script?
Try:
exec('"pushd d:\class & java login username password id name Daily Detailed 20120820"',$output,$return);)The
&is because you have multiple commands, and the context is not going to be remembered between exec’s.Also, php exec calls
cmd /con your exec command, so you need an extra pair of quotes around the whole call.(
cmd /?from your command prompt explains more on/c).