On Sun, 03 Apr 2016 18:20:31 +1000, Cameron Simpson wrote: > In particular, you want the subprocess' output. As written, your code > sets "output" to the Popen object. You actually want to set it to the > .stdout attribute of that object, which is the output from the > subcommand.
Based on your above hints, I try to use the following codes: output = Popen(""" /bin/bash <<EOF source ~/.profile.d/environment-module-systems/modules.sh export PATH=$MODULESHOME/../default/bin:$PATH module add intel/parallel_studio_xe_2015 env -0 EOF """, shell=True).stdout But I meet the following error: Traceback (most recent call last): File "/home/werner/software/hpc/dft-to-study/jasp/jasp.git/jasp/bin/ runjasp.py", line 138, in <module> os.environ.update(line.partition('=')[::2] for line in output.split ('\0')) AttributeError: 'NoneType' object has no attribute 'split' While the following code will work smoothly: output = Popen(""" /bin/bash <<EOF source ~/.profile.d/modules/modules.sh export PATH=$MODULESHOME/../default/bin:$PATH module add intel/parallel_studio_xe_2015 env -0 EOF """, shell=True, stdout=PIPE).communicate()[0] Any hints on this issue? Regards -- .: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :. -- https://mail.python.org/mailman/listinfo/python-list