note 19729 modified in function.popen by danbrown
| From: | danbrown@php.net | Date: | Mon, 02 Mar 2009 13:42:24 +0000 |
| Subject: | note 19729 modified in function.popen by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-151341@lists.php.net to get a copy of this message | ||
ive tried using popen using bidirectional pipes without working for obvious reasons, but i managed
to create a simple script that managed to take care of the problem. This example is for gpg
encryption.
<?php
$message = "this is the text to encrypt with gpg";
$sendto = 'Dummy Key <another@fake.email>';
system("mkfifo pipein");
system("mkfifo pipeout");
system("gpg --encrypt -a -r '$sendto' > pipeout < pipein &");
$fo = fopen("pipeout", "r");
$fi = fopen("pipein", "w");
fwrite($fi, $message, strlen($message));
fclose($fi);
while (!feof($fo)) {
$buf .= fread($fo, 1024);
}
echo $buf;
unlink("pipein");
unlink("pipeout");
?>
If anyone has a better way of doing this I would love to see it.
--was--
ive tried using popen using bidirectional pipes without working for obvious reasons, but i managed
to create a simple script that managed to take care of the problem. This example is for gpg
encryption.
<?
$message = "this is the text to encrypt with gpg";
$sendto = 'Dummy Key <another@fake.email>';
system("mkfifo pipein");
system("mkfifo pipeout");
system("gpg --encrypt -a -r '$sendto' > pipeout < pipein &");
$fo = fopen("pipeout", "r");
$fi = fopen("pipein", "w");
fwrite($fi, $message, strlen($message));
fclose($fi);
while (!feof($fo)) {
$buf .= fread($fo, 1024);
}
echo $buf;
unlink("pipein");
unlink("pipeout");
?>
If anyone has a better way of doing this I would love to see it.
http://php.net/manual/en/function.popen.php