I was wondering whether
subprocess.call("if [ ! -d '{output}' ]; then mkdir -p {output}; fi", shell=True)
will be interpreted by sh
or zsh
instead of bash
in different servers.
What should I do to make sure that it's interpreted by bash
?
http://docs.python.org/2/library/subprocess.html
On Unix with shell=True, the shell defaults to /bin/sh
Note that /bin/sh is often symlinked to something different, e.g. on ubuntu:
$ ls -la /bin/sh
lrwxrwxrwx 1 root root 4 Mar 29 2012 /bin/sh -> dash
You can use the executable
argument to replace the default:
... If shell=True, on Unix the executable argument specifies a replacement shell for the default /bin/sh.
subprocess.call("if [ ! -d '{output}' ]; then mkdir -p {output}; fi",
shell=True,
executable="/bin/bash")