Hello all,
I am currently having a problem calling certain executable files using PHP 4.4.2 and Windows XP. I am currently trying to get GPG to encrypt a file for me using PHP.
If I do system('del c:\\temp\\order.txt',$retval); I have no problem with the command executing.
If I do
system ('C:\\Program Files\\GNU\\GnuPG\\gpg.exe -r jimmy --encrypt c:\\temp\\order.txt',$retval); nothing happens.
I created a small C program using the system function to call GPG and it worked fine, but when I tried to have PHP's system function call my C program nothing happens.
Any advice as to what the problem could be?
Thank you.
Php system problem
Moderator: General Moderators
please tryand post the output.
Code: Select all
echo "<pre>gpg.exe\n";
flush();
passthru('C:\\Program Files\\GNU\\GnuPG\\gpg.exe -r jimmy --encrypt c:\\temp\\order.txt',$retval);
var_dump($retval);
echo "</pre>\n";and?
Code: Select all
passthru('C:\\Program Files\\GNU\\GnuPG\\gpg.exe --help',$retval);Code: Select all
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
$path = 'C:\\Program Files\\GNU\\GnuPG';
// $path = 'C:\\Programme\\GNU\\GnuPG';
$cfile = $path . '\\volka_test.cmd';
$cmds = "C:
cd $path
cd
gpg.exe --help
echo done.";
file_put_contents($cfile, $cmds) or die('cannot write to '.$cfile);
passthru($cfile, $retval);
var_dump($retval);
unlink($cfile);Ok I messed around and got a little bit further.
I changed the code to passthru('gpg --help',$retval); and got the help info to output back to the browser.
I also imported a public key since when PHP runs GPG it doesn't see the public key that I was seeing when I ran the command.
Now the problem is that when I run
passthru('gpg -r jimmy --output s.txt --encrypt c:\\temp\\order.txt',$retval);
the browser just keeps waiting and the file still isn't encrypted.
I changed the code to passthru('gpg --help',$retval); and got the help info to output back to the browser.
I also imported a public key since when PHP runs GPG it doesn't see the public key that I was seeing when I ran the command.
Now the problem is that when I run
passthru('gpg -r jimmy --output s.txt --encrypt c:\\temp\\order.txt',$retval);
the browser just keeps waiting and the file still isn't encrypted.