daverave has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I noticed that when I use backticks in perl the commands are executed using sh, not bash, giving me some problems.

How can I change that behavior so perl will use bash?

Thanks, Dave

Replies are listed 'Best First'.
Re: backticks - bash instead of sh
by Corion (Patriarch) on Jul 30, 2010 at 17:52 UTC

    This is documented, see perlop on qx. If you don't want /bin/sh, use system or IPC::Open2 or IPC::Open3 or explicitly invoke /bin/bash or whatever shell you want.

      The command I'm trying to run is paste filename <(cut -d \" \" -f 2 filename2 | grep -v mean) >> filename3

      Even if I begin with `/bin/bash ...` I get "sh: Syntax error: "(" unexpected".

        Write it in Perl, or just use a bash file and call it through perl.

        I don't think this is a hard job to do in perl.

        You'll have to read tow files and output them in 1 file... and this has been done many times before over here ... use the search button in the top of the site to look that up

Re: backticks - bash instead of sh
by DStaal (Chaplain) on Jul 30, 2010 at 18:16 UTC

    See Corin's answer, but also: `bash -c 'command'` should also work. (That is: have sh call bash.)

      Thank you.