I am trying to automate deployment process using the python. In deployment I do "dzdo su - sysid" first and then perform the deployment process. But I am not able to handle this part in python. I have done similar thing in shell where I used following piece of code,
/bin/bash
psh su - sysid << EOF
. /users/home/sysid/.bashrc
./deployment.sh
EOF
this handles execution of deployment.sh very well. It does the sudo and then execute the script with sysid id. I am trying to do similar thing using python but I am not able to find any alternative to << EOF in python.
I am using subprocess.Popen to execute dzdo part, it does the dzdo, but when I try to execute next command for e.g. say "ls -l", then this command will not get executed with the sysid, instead, i had to exit from sysid session and as soon as i exit, it will execute "ls -l" in my home directory which is of no use. Can someone please help me on this?
And one more thing, in this case I am not calling any deployment.sh but I will call commands like cp, rm, mkdir etc.