I'm trying to automate the following via Fabric:
- SSH to a remote host.
- Execute a python script (the Django management command
dbshell). - Pass known values to prompts that the script generates.
If I were to do this manually, it would like something like:
$ ssh -i ~/.ssh/remote.pem [email protected] [email protected]$ python manage.py dbshell postgres=> Password For ubuntu: _____ # i'd like to pass known data to this prompt postgres=> # i'd like to pass known data to the prompt here, then exit =========
My current solution looks something like:
from fabric.api import run from fabric.context_managers import settings as fabric_settings with fabric_settings(host_string='10.10.10.158', user='ubuntu', key_filename='~/.ssh/remote.pem'): run('python manage.py dbshell') # i am now left wondering if fabric can do what i'm asking....