subprocess.Popen() を使用すると、「実行可能」パラメーターを介して選択したシェルを渡すことができます。
「/bin/tcsh」を渡すことを選択しましたが、tcsh に私の~/.cshrc
.
tcsh のマニュアルには、そのためには to を渡す必要があると書かれ-f
て/bin/tcsh
います。
Popen に -f オプションを付けて /bin/tcsh を実行させるにはどうすればよいですか?
import subprocess
cmd = ["echo hi"]
print cmd
proc = subprocess.Popen(cmd, shell=False, executable="/bin/tcsh", stderr=subprocess.PIPE, stdout=subprocess.PIPE)
return_code = proc.wait()
for line in proc.stdout:
print("stdout: " + line.rstrip())
for line in proc.stderr:
print("stderr: " + line.rstrip())
print return_code