Clodoaldo Pinto Neto wrote: > Output from the shell: > > [EMAIL PROTECTED] teste]$ set | grep IFS > IFS=$' \t\n' > > Output from subprocess.Popen(): > > >>> import subprocess as sub > >>> p = sub.Popen('set | grep IFS', shell=True, stdout=sub.PIPE) > >>> p.stdout.readlines()[1] > "IFS=' \t\n" > > Both outputs for comparison: > IFS=$' \t\n' > "IFS=' \t\n" > > The subprocess.Popen() output is missing the $ and the last ' > > How to get the raw shell output from subprocess.Popen()?
You are getting the raw shell output, it's just that subprocess uses the default shell (/bin/sh) and not your personal shell. Try running /bin/sh and run the set|grep command. I can't see any obvious way to ask subprocess to use a shell other than the default. If you need a particular shell, you could use a shell script, e.g. myscript.sh: #!/bin/bash set|grep IFS and call that with shell=False p = sub.Popen('/path/to/myscript.sh', stdout=sub.PIPE) -- http://mail.python.org/mailman/listinfo/python-list