execute shell script from python, needs sys.argv
timr at probo.com
Sat Nov 6 23:53:48 CET 2010
Benjamin Kaplan <benjamin.kaplan at case.edu> wrote:
>Python is not the shell. Shell commands are not python commands. You
>need either a string or a list of strings, so any literal have to be
>in quotes. Also, subprocess can't handle the redirection. You need to
>run it as two commands.
>proc1 = subprocess.Popen(["cat", sys.argv],stdout =
>subprocess.PIPE, shell = True)
>proc2 = subprocess.Popen(["fastx_trimmer", "-n", "COUNT", "-o",
I KNOW that we're still working on syntax here, and that it's too early for
optimization, but it bothers me to see "cat" as the first thing in a
pipeline. You don't actually need two steps here at all:
proc1 = subprocess.Popen(
["fastx_trimmer", "-n", "COUNT", "-o", sys.argv,
With this, I don't think you even need "shell=True".
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list