tags:

views:

170

answers:

4

Hi,

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

A: 

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,

Peter
+2  A: 

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

Qrilka
i don't understand why he sues OS specific extension, either.
dusoft
A: 

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

Nicolas
+1  A: 

i found the solution here

http://stackoverflow.com/questions/814586/calling-mysql-exe-using-php-exec-doesnt-work

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

yuxia