0

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

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.