Python subprocess and shell input redirection

On the unix command line, I can do:

paste <(echo A) <(echo B)

      

However, when I try to do this:

import subprocess
subprocess.call('paste <(echo A) <(echo B)', shell = True)

      

I am getting this error:

/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `paste <(echo A) <(echo B)'

      

Unable to redirect shell input using subprocess module?

+3


source to share


1 answer


Many things are used by default /bin/sh

as a wrapper around the selection. /bin/sh

often not bash.

/bin/sh

your system most likely does not support process substitution.



Specify subprocess.call

use /bin/bash

instead of shell and work.

+1


source







All Articles