HELP: Strange behaviour of subprocess

From: Pekka Niiranen (pekka.niiranen_at_wlanmail.com)
Date: 12/31/04


Date: Fri, 31 Dec 2004 14:53:10 +0200

Hi there

I have installed Cygwin to my w2k machine and use
Python to execute Bash -shell scripts. I noticed
that in script below parameter "shell=False"
causes raw_input() to fail; the only way to
stop script is to kill the Dos window where
it is run (The Bash shell runs OK listing
directory contents to screen).

Any comments anybody?

---script starts--
import os, subprocess, sys

try:
     retcode = subprocess.call("c:\\cygwin\\bin\\bash.exe -c\
        /usr/bin/ls", shell=False)
     if retcode < 0:
         print >>sys.stderr, "Child was terminated by signal", -retcode
     else:
         print >>sys.stderr, "Child returned", retcode
except OSError, e:
     print >>sys.stderr, "Execution failed:", e
raw_input("press any key")

---script ends--



Relevant Pages

  • Re: Problems to launch scripts
    ... > Since the begining I experience troubles to execute bash ... and then the script has to have the executable bit set, ... $ chmod a+x script # for user, ... > does not want to execute it. ...
    (alt.os.linux.suse)
  • Re: consent to monitoring banner for ssh
    ... Have you tried implementing this by replacing the user's shell (in ... /etc/passwd) with a script that calls bash if they say OK? ... How about your script, and if they say yes, execute bash, and if they don't, /bin/false? ...
    (RedHat)
  • Re: perl to python
    ... sed and perl can let you do all that quick command line stuff. ... into a full blown script. ... scripts, call it from the python interpreter, whatever I need. ... If I stick to the traditional unix approach, ...
    (comp.lang.python)
  • Re: Learning Tkinter
    ... and how the command option is used to call the function callback. ... gui programming to see if the python programs I have written can be made ... search their computer for this file, execute the python code and then ... This is the meaning of the test on __name__: this magical variable is set to the string '__main__' if and only if the current script is the top-most one, i.e the one you ran python on. ...
    (comp.lang.python)
  • Correct way to handle independent interpreters when embedding in a single-threaded C++ app
    ... The Python interpreter is ... interpreter and provides an extension module to expose ... manage each script runs in a new interpreter. ... globals that could cause issues. ...
    (comp.lang.python)