using bash process substitution in perl pipe?

Discussion in 'Perl Misc' started by Peng Yu, Jun 5, 2010.

  1. Peng Yu

    Peng Yu Guest

    I want to use bash instead of sh because I need the process
    substitution. But by default perl use sh instead of bash. Is there a
    way to let perl use bash?

    #!/usr/bin/perl

    use warnings;
    use strict;

    open(IN, 'ls <(echo main.txt) |');
    foreach (<IN>) {
    print
    }
     
    Peng Yu, Jun 5, 2010
    #1
    1. Advertising

  2. Peng Yu

    Alan Curry Guest

    In article <>,
    Peng Yu <> wrote:
    >I want to use bash instead of sh because I need the process
    >substitution. But by default perl use sh instead of bash. Is there a
    >way to let perl use bash?
    >
    >#!/usr/bin/perl
    >
    >use warnings;
    >use strict;
    >
    >open(IN, 'ls <(echo main.txt) |');
    >foreach (<IN>) {
    > print
    >}


    call bash -c 'your command' explicitly, like this:

    open IN, '-|', $shell, '-c', $cmd

    Where $shell is 'bash' or '/usr/bin/bash' or something else that names the
    shell you want, and $cmd is the 'ls <(echo main.txt)' string

    --
    Alan Curry
     
    Alan Curry, Jun 6, 2010
    #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. William Park

    (patch for Bash) GTK+2 + Bash

    William Park, Jul 11, 2005, in forum: XML
    Replies:
    3
    Views:
    2,302
    William Park
    Jul 14, 2005
  2. j. del
    Replies:
    13
    Views:
    18,739
    Howard
    Mar 28, 2005
  3. hofer
    Replies:
    11
    Views:
    2,639
  4. Fred

    executing bash comands with pipe

    Fred, Jun 26, 2007, in forum: Perl Misc
    Replies:
    4
    Views:
    150
    Jürgen Exner
    Jun 26, 2007
  5. Tarek Elganainy

    pipe perl output to a bash command error

    Tarek Elganainy, Feb 2, 2009, in forum: Perl Misc
    Replies:
    6
    Views:
    320
Loading...

Share This Page