Re: question about using temporary named pipe in the string for system

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/05/06, Jochem Maas <jochem@xxxxxxxxxxxxx> wrote:
Ginger Cheng wrote:
> Hello, PHP gurus,
>         I have a command that I want to run using system function. The
> command exploits temporary named pipes in the place of temporary files.
>           my command is
> paste   <(cut -f1  file1)  <(cut -f2  file2)    > final_file
>
>          It works perfectly well if I just type it in my interactive
> shell.  But if I do a
>
> <?php $cmd = " paste   <(cut -f1  file1)  <(cut -f2  file2)    >
> final_file";
> system($cmd);
> ?>
>
>          I got the syntax error msg as
> "sh: -c: line 1: syntax error near unexpected token `('".   I have tried

I notice that the 'sh' shell is being used according to your error output,
I'm guessing that maybe your interactive shell is running something like 'bash'
and that this discrepency might the root cause of the problem. just a guess -
I don't know how you would define another shell for php to use either :-/.

That's exactly what's causing it.

One thing the OP can do is invoke bash to run his command line:

  $cmd = '/bin/bash -c  "paste <(cut -f1 file1) <(cut -f2 file2) > file3"';

Alternatively, arrange the command line more efficiently:

  $cmd = 'paste file1 file2 | cut -f1,6 > file3';

(replacing the '6' with the correct field number)

-robin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux