Using Python to open a shell environment, run a command and exit environment

前端 未结 5 1169
感动是毒
感动是毒 2020-12-19 04:39

I\'m trying to automate a process using python. If I am just in the terminal the workflow looks like:

user:> . /path/to/env1.sh
user:> python somethin         


        
5条回答
  •  无人及你
    2020-12-19 05:35

    p = subprocess.Popen(". /path/to/env.sh", shell = True, stdout=subprocess.PIPE).communicate()
    subprocess.call("python something.py", shell = True).communicate()
    

提交回复
热议问题