so I know python can execute shell commands using subprocess.call()
But I normally use tcsh, and I have a .tcshrc that loads a lot of environmental variables to make my shell comfortable.
How do I make my subprocess.call() realize that -- execute my commands in tcsh, load my .tcshrc file?
asked Jun 11, 2015 at 12:54
CuriousMind
15.9k23 gold badges91 silver badges128 bronze badges
1 Answer 1
Explicitly invoke tcsh to execute the respective cmds, like this (replace env with your specific cmd arg list:
~/> cat tst.py
#!/usr/bin/python -u
import subprocess
subprocess.call(['/usr/bin/tcsh', '-c', 'env'])
~/> ./tst.py | grep ^DISPLAY
DISPLAY=:0
~/>
answered Jun 11, 2015 at 13:36
Dan Cornilescu
39.8k12 gold badges61 silver badges102 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default