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

From: Date: Wed, 10 May 2006 23:40:58 +0000
Subject: Re: question about using temporary named pipe in the string for system
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-235947@lists.php.net to get a copy of this message
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 :-/. another thing to try is the backticks operator, as described on the following page: http://php.net/manual/en/language.operators.execution.php
to 'escapeshellcmd' the command and run it in system, then I got paste: invalid option -- f Try `paste --help' for more information.
        Also tried exec.  I really want to take advantage of the temporary named pipes so I don't have to worry about the temporary files generated.  I've been googling around without much help.  Could anyone plz give me some hint? Thanks a lot
         ginger


« previous php.general (#235947) next »