Categories
python

Using Python Version Management: Pyenv

https://github.com/pyenv/pyenv Install via homebrew. Install multiple versions of python. You can also use this within a virtual environment. pyenv install 3.6.0 Add pyenv init to your shell to enable shims and autocompletion. Please make sure eval “$(pyenv init -)” is placed toward the end of the shell configuration file since it manipulates PATH during the initialization. […]

Categories
python

Using Python to Automate SSH Connection and Run Commands

We will be using a  http://fitztrev.github.io/shuttle/ and the pexpect python library. Here is what the shuttle menu looks like. Mine could be named better. #!/usr/bin/python from pexpect import * import pexpect PROMPT = [‘# ‘, ‘>>> ‘, ‘> ‘,’\$ ‘] def send_command(child, cmd): child.sendline(cmd) child.expect(PROMPT) print child.before child.interact() def connect(user, host, password): ssh_newkey = ‘Are you […]