Re: Piping Mime String to Metamail Fails

From: Date: Fri, 13 Jul 2001 23:52:51 +0000
Subject: Re: Piping Mime String to Metamail Fails
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-57832@lists.php.net to get a copy of this message
Don Read wrote: > On 13-Jul-01 Jeff Hill wrote: > > Don Read wrote: > >> On 13-Jul-01 Jeff Hill wrote: > >> > I've tried everything I can to pipe a string with mime content to > >> > metamail, but it fails in every variation of: > >> > > >> > exec("echo $mime_string | /usr/bin/metamail -d -q -r -w -x -y ", > >> > $met_res) ; > >> > >> what about "/bin/echo ..." > > > > Nope, but I do appreciate the thought. Using "/bin/echo" just results in > > $met_res becoming an empty array, as does my example string. > > > > Huh ? > $cmd='/bin/echo' ." $mime_string | /usr/bin/metamail -d -q -r -w -x -y "; > echo ' cmd is:<br>', $cmd, '<p>'; > fpassthru($cmd); Well, I really do appreciate the help; maybe I'm misunderstanding something. Using your statement above and executing the php script from bash, I first get the results of your echo statement: cmd is:<br>/bin/echo . . . then the $mime_string, and then on the last line, | /usr/bin/metamail -d -q -r -w -x -y <p><br> After your echo statement, the fpassthru($cmd) results come back: <b>Warning:</b> Supplied argument is not a valid File-Handle resource in <b>./mimescript_test.php</b> on line <b>9</b><br> The entire contents of this mimescript_test.php are: --------------------------------------------------- #!/usr/local/bin/php -q <?php $fp0 = fopen('php://stdin','r') or die("couldnt open stdin"); while(!feof($fp0)) { $mime_string .= fgets($fp0,4096); } $cmd='/bin/echo' ." $mime_string | /usr/bin/metamail -d -q -r -w -x -y "; echo ' cmd is:<br>', $cmd, '<p>'; fpassthru($cmd); ?> ---------------------------------------------------- As it seems fpassthru is supposed to work with the file pointer rather than string, I did try using $fp0 rather than $mime_string, but I got "not a valid File-Handle resource". If I substitute exec for fpassthru and add a $return to capture what comes back, I get an empty array (I get a response of "Array" when attempting to echo the $return variable, when I echo $return[0], etc., I get nothing. If I substitute system for fpassthru, I get only "127" when I echo the $return. I'm not the expert, but it certainly seems the problem lies in getting the /bin/echo command pipe the string to metamail, and I'm not certain how to make it do so. Regards, Jeff Hill

« previous php.general (#57832) next »