I'm pretty new to php\linux and I'm trying to encrypt a file using gpg from
a php page on a linux box and it's not working. The following code works
for executing 'ls', but not gpg...
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read
from
1 => array("pipe", "w"), // stdout is a pipe that the child will write
to
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to
write to
);
//LINE BELOW DOESN'T WORK
//$process = proc_open(gpg --output encmail.txt --recipient
so*****@domain.com --always-trust --armor --yes --encrypt mail.txt",
$descriptorspec, $pipes);
//LINE BELOW WORKS
$process = proc_open("ls", $descriptorspec, $pipes);
if (is_resource($process)) {
while (!feof($pipes[1])) {
echo fgets($pipes[1], 1024);
}
fclose($pipes[1]);
$return_value = proc_close($process);
echo "command returned $return_value\n";
}
When I try to execute gpg, the value returned is 2, but that means nothing
to me. Am I doing something wrong from the php side of things or am I
overlooking something on the server?
Thanks.