so I have the following script
$execStr = 'cd /D Z:\\folder'
exec($execStr);
$execStr = 'java -jar somejar.jar';
exec($execStr);
the jar does some operations on a mysql database...
but when I run it, it appears that the jar did not run properly because the database was unchanged
but then when I run the exact same strings from the command line it would work properly
what am I doing wrong?
shell_exec('/path/to/java -jar Z:\folder\somejar.jar');
where you sub /path/to to the real place your java is run from.
Try this:
$execStr = 'java -jar Z:\folder\somejar.jar';
shell_exec($execStr);
Try running dir
or ls
after your cd
to make sure the exec environment is persisting from one command to the next.
I guess that's because when you call java -jar ...
you're no longer in Z:\folder
directory. Try a single command:
java -jar "Z:\folder\somejar.jar"