Python2: subprocess.Popen() has another output as it runs direct on console
Question: When i am running a program in the console, i get some text output. When i am
running the same program in Popen(..), with the same parameters, stdout and
stderr are empty.

I tried everything i could imagine like shell=False and shell=True, set
stdout=subprocess.PIPE, did a os.chdir() to change into the directory of this
program, try p.wait() and p.communicate(), set the command as a list and as a
string, but nothing works.

example:

    
    
    p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
    out, err = p.communicate()
    

\--> out and err are empty strings, but if i ran this command in console i get
a real output. Command is with fullpath, so its regardless where the command
will be started.

My question is, are there mechanisms for programms to detect they weren't run
in a real console? If so, how can i cheat.

Or miss i something?

(Python 2.7.8. x32 in Win7 x64)


Answer: 
    from subprocess import Popen, STDOUT, PIPE
    p = Popen(command, shell=True, stdout=PIPE, stderr=STDOUT, stdin=PIPE)
    while p.poll() is None:
        print(p.stdout.read())
    p.stdout.close()
    p.stdin.close()
    

Try this and see if it makes any difference. Also make sure `command` is a
string and not a list/touple, `shell=True` for whatever reason works better or
only with strings. Also note that `shell=True` will get you hanged because
it's insecure etc.

Also skipping `.communicate()` you'll need to tap off `stdout` otherwise the
buffer will get full and you might hang both yours and the child process.

* * *

_If this doesn't work, please provide more information. Such as the command
used and the expected output (at least first few lines)_

