php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26532 passthru does not work with subshells
Submitted: 2003-12-05 08:30 UTC Modified: 2003-12-05 09:25 UTC
From: arne at fotos dot dyndns dot biz Assigned:
Status: Not a bug Package: Program Execution
PHP Version: 4.3.4 OS: LINUX
Private report: No CVE-ID: None
 [2003-12-05 08:30 UTC] arne at fotos dot dyndns dot biz
Description:
------------
when I have 2 files t and t2 and I try to diff them with

diff <(cat t) <(cat t2) LINUX-shell produces 2 meta-files (/dev/fd/[00-99]) to pipe into the diff command. Thats usual, thats basic.
If I try to use the same command in passthru("diff <(cat t) <(cat t2)"); I run into errors:
sh: -c: line 1: syntax error near unexpected token '('
sh: -c: line 1: 'diff <(cat t) <(cat t2)'
The files are in the PATH and I can see output of t when I do: passthru("cat t"); what means that cat is available too.


Reproduce code:
---------------
file X.php4:
-----snip--------
<?php passthru("diff <(cat t) <(cat t2)"); ?>
-------snap------

shell:> php X.php4

Expected result:
----------------
1,3c1,4
< MIKE
< bravo
< charly
---
> VANDA
> PHP
> Utah
> russia

Actual result:
--------------
sh: -c: line 1: syntax error near unexpected token '('
sh: -c: line 1: 'diff <(cat t) <(cat t2)'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-05 09:17 UTC] iliaa@php.net
You cannot pipe data into programs executed by PHP.

Just do passthru("diff t t2");
 [2003-12-05 09:25 UTC] arne at fotos dot dyndns dot biz
well, I can, because this works: passthru("cat t | diff - t2"); that means just a pipe stack (or anything else) seems to be corrupt


BRgds,
Arne
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 11:01:31 2024 UTC