how can I input a file and run an asynchronously command on it in python?
Question: I'm trying to write a script that asks for an input file and then runs some
command on it. when I run the script it askes me for filename and when I give
the file (e.g example.bam) then I get this error:

> NameError: name 'example.bam' is not defined

I tried many things but I couldn't fix it. Can someone tell me what is wrong?

This is my comand:

    
    
    from subprocess import call
    filename = input ("filename: ");
    with open (filename, "r") as a:
        for command in ("samtools tview 'a' /chicken/chick_build2.1_unmasked.fa",):
            call(command, shell=True)
    

This is a short version of my command: it has to do much more stuff. I'm also
thinking to input 4-6 files at same time (perhaps this information is helpful
to clarify my intentions).


Answer: `input` is equivalent to `eval(raw_input(prompt))`. So what your script
currently tries to do is interpret your input ("example", in your case), and
execute as if it were a statement in your script. For user input (and might I
simply say "for any input" -- unless you know what you're doing), always use
the `raw_input` function.

So, to solve it, replace `input` with `raw_input`:

    
    
    filename = raw_input("filename: ")
    

