I'm trying to execute a shell command via Python code, but I'm not capable to understand why it is failing.
When printing the command and pasting it to the shell to try executing it directly works perfectly fine, that's the strange part.
From Python I'm getting the following:
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `/DATA/NGS/ngs_software/bioinfoSoftware/bwa_current/bwa mem ... --threads 4 -T /tmp/samTemp -'
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
out = process.stdout.readline()
out = out.decode("utf-8").strip('\n')
Your command contains a process substitution, but
Popen runs its command using
/bin/sh. When run as
bash does not allow process substitutions. You can explicitly request that the command be run with
bash using the
process = subprocess.Popen(cmd, shell=True, executable='/bin/bash', stdout=subprocess.PIPE)