On 13-Jul-01 Jeff Hill wrote:
> 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.
>
ok, i was thinking system(), but was on the fpassthru page in the manual ...
sorry.
But looking at your while (!feof()) loop above ...
Hey, there are limits to a shell argument length, ya know.
alternative:
$p=popen('/usr/bin/metamail -d -q -r -w -x -y','w');
fwrite($p, $mime_string);
pclose($p);
Regards,
--
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]