1

I encountered some problems with the shell function in php. I want to execute a java program on the server by running a php function on a php webpage.

The java program writes some chars to a local file on the server.

test.php

<?php

   $WshShell = new COM("WScript.Shell");
   $cmd = '  "C:\\Program Files\\Java\\jdk1.6.0_14\\bin\\java" Importer 1 2 updated.txt 7';

   $WshShell->exec($cmd);
   echo "okay";
?>

When test.php is executed via command line on the server,

c:\php test.php

the java program runs.

However, if I executed it through web browser, the Java program is not called.

http://127.0.0.1/test.php

Is it because the Apache user is not allowed to use the command line functionality on windows?

System configuration:

Microsoft windows XP, Professional X64 edition, Version 2003, service pack 2 PHP version: 5.2.6.6 Apache 2.2 IIS 6

1
  • 2
    try adding error_reporting (E_ALL); on top to see what error you get. Commented Jul 31, 2009 at 5:48

4 Answers 4

2

Why don't you use ordinary PHP 'exec' function?

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

1 Comment

i don't understand why he sues OS specific extension, either.
1

i found the solution here

Calling MySQL exe using PHP exec doesn't work

it is not the OS problem, but "quotes" problem.

Comments

0

What error do you got ?

Not really knowing php i do however have a question: You dont fully qualify the file that the Java program needs to update, you sure its not written but under some directory where your php server is installed,

Comments

0

Your problem could be due to PHP running with Apache under "safe_mode"...You can check this in your php.ini file.

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.