On a 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 get this error:
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `paste <(echo A) <(echo B)'
Is it not possible to do shell input redirection with the subprocess module?
asked Sep 18, 2014 at 11:21
tommy.carstensen
9,66215 gold badges70 silver badges113 bronze badges
1 Answer 1
Many things by default use /bin/sh as the shell of choice. /bin/sh is often not bash.
The /bin/sh on your system most likely does not support process substitution.
Convince subprocess.call to use /bin/bash as the shell instead and it should work.
answered Sep 18, 2014 at 12:59
Etan Reisner
81.8k8 gold badges120 silver badges154 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
tommy.carstensen
Thank you again. This did the trick: subprocess.call('paste <(echo A) <(echo B)', shell = True, executable='/bin/bash')
jfs
@tommy.carstensen: even
/bin/bash if called using name /bin/sh may use different compatibility mode i.e., no process substitutions.Explore related questions
See similar questions with these tags.
default
/bin/shas your shell which doesn't do that. You need to try to force it to use/bin/bash.