2

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?

1
  • 1
    What happens if you combine the two exec's? Commented Jul 24, 2011 at 22:54

4 Answers 4

3

shell_exec('/path/to/java -jar Z:\folder\somejar.jar');
where you sub /path/to to the real place your java is run from.

Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

$execStr = 'java -jar Z:\folder\somejar.jar';
shell_exec($execStr);

Comments

1

Try running dir or ls after your cd to make sure the exec environment is persisting from one command to the next.

Comments

0

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"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.