DjangoDev
DjangoDev

Reputation: 957

exec command is not working in php script

I have a java file and it will generate itunes report. I want to execute this within my php script. Im using the exec() function in php:it is working properly in linux.But not in windows.Am i missing anything?Any help will be appreciated.

exec("java Autoingestion ".'USERNAME'." '".'PASSWORD'."' ".'VENDORID'." ".'REPORT_TYPE'." ".'DATE_TYPE'." ".'REPORT_SUB_TYPE'." ".'2012-05-28'."",$output,$return);

Upvotes: 0

Views: 218

Answers (2)

Sverri M. Olsen
Sverri M. Olsen

Reputation: 13283

Check the result of the string concatenation. It looks a little iffy:

"java Autoingestion USERNAME 'PASSWORD' VENDORID REPORT_TYPE DATE_TYPE REPORT_SUB_TYPE 2012-05-28"

You are not using any variables, or anything else, so there is no reason to concatenate stuff.

Even if the capitalized parts are placeholders you do not have to concatenate. Just use variable interpolation:

$username = 'USERNAME';
$password = 'PASSWORD';
$exec = "java Autoingestion '{$username}', '{$password}', ...";
exec($exec);

Upvotes: 1

heapOverflow
heapOverflow

Reputation: 1285

I suggest you to check for the script output (both on stdout and stderr).

Check also the environment variables you need to run the script.

Upvotes: 0

Related Questions