how to use open with many input streams and capture output?

Discussion in 'Perl' started by Pawel Banys, Jul 8, 2004.

  1. Pawel Banys

    Pawel Banys Guest

    Hello,

    There is an operation which can be performed at the shell prompt the
    following way:

    some_prg [some_inputfile_1] [some_inputfile_2] > result_file

    However, before "some_prg" can use files, they have to be converted and it
    can be done like this:

    some_prg <(convert inputfile_1) <(convert inputfile_2) > result_file

    It works perfectly at shell prompt.

    I would like to start the above sequence in perl script using "open"
    command:

    open(SOME_OUTPUT,"some_prg <(convert inputfile_1) <(convert inputfile_2) |
    ");

    When I try to run the script and capture SOME_OUTPUT, I get the following
    error:

    sh: -c: line 1: syntax error near unexpected token `('
    sh: -c: line 1: `some_prg <(convert file_1) <(convert file_2)'

    Is there any way to solve that syntax error without writing extra shell
    scripts as I would like to have all the code in a single perl script?

    Thank you for any help.

    Pawel Banys
     
    Pawel Banys, Jul 8, 2004
    #1
    1. Advertising

  2. Pawel Banys

    Joe Smith Guest

    Pawel Banys wrote:

    > some_prg <(convert inputfile_1) <(convert inputfile_2) > result_file
    >
    > It works perfectly at shell prompt.


    Which shell? That syntax is not valid for the /bin/sh (Bourne) shell,
    which is what perl calls upon. For the Bourne shell, try this:

    (convert inputfile_1; convert inputfile_2) | some_prog > result_file.

    -Joe

    P.S. Next time post to comp.lang.perl.misc, not comp.lang.perl .
     
    Joe Smith, Jul 8, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ike
    Replies:
    1
    Views:
    1,976
  2. Max
    Replies:
    7
    Views:
    9,191
  3. Matthew David Hills

    input streams, setw(), and strings vs. char*?

    Matthew David Hills, Sep 5, 2003, in forum: C++
    Replies:
    1
    Views:
    610
    John Harrison
    Sep 5, 2003
  4. Aziz
    Replies:
    1
    Views:
    425
    Oliver Wong
    Jun 28, 2006
  5. Kza
    Replies:
    4
    Views:
    441
    Andrew Koenig
    Mar 3, 2006
Loading...

Share This Page