I have a use-case, where I need to run Linux commands on a remote machine. Currently, I am using Fabric to achieve the functionality. However, I was wondering if it would be better to use Shell script rather than Python.
My use case is to set up some services, set up dbs in MySQL, and additionally create some scripts which would then be executed on the remote machine. For now, I have about 50-60 lines of commands embedded in Fabric calls.
Everything has to be executed on the remote machine, and for the same, I have created a connection to the machine using Fabric, and I run commands with a run
/sudo
function. For all the different lines of commands, I am using a separate run method.
If I have to use a shell script, I would further have two ways:
- Use a Fabric call to run the script on the remote machine.
- Make the script
ssh
into the other machine, and run it there.
What would be the best Pythonic way to achieve the functionality?