Reputation: 727
I had a working code, which now I am unable to run due to some issues.
I am facing the following issues:
I am prompted for password, as I run the file using python /path/to/file.py
Even if I use fab -l, this file is invoked and I am again prompted for password.
Just to let you know, I have a lot of .py (including fabfile.py) files in the directory which are using fabric and other libraries.
Here is a snippet of my code:
from fabric.api import *
env.key_filename = /path/to/my/pem/file
def mem_usage():
'''Check free mem'''
run('free -m')
execute(mem_usage, host="user@IP_or_hostname")
Please help with my understanding:
How can I ssh using pem file without passing the path through command-line arguments
How can I run the code (file named foo.py)
Any pointers would be highly appreciated.
Upvotes: 2
Views: 872
Reputation: 727
So, I found the solution to my question.
It was just a stupid thing not to check my pem file, which was secured with a passphrase.
The python file can be named anything, as far as it has an execute method - and it is executed just like a normal python program. Let's say foo.py, then it will be executed using python foo.py
Upvotes: 2