note 19729 added to function.popen
| From: | nricciardi at mindspring dot com | Date: | Fri, 08 Mar 2002 21:38:45 +0000 |
| Subject: | note 19729 added to function.popen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-27530@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.
<?
$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://www.php.net/manual/en/function.popen.php
http://master.php.net/manage/user-notes.php?action=edit+19729
http://master.php.net/manage/user-notes.php?action=delete+19729
http://master.php.net/manage/user-notes.php?action=reject+19729