$FHHOME/fabfile/cisco.py
I use Fabric for simple tasks and repetitive tasks.
$ fab -l |grep -F cisco $ echo xx.xx.xx.xx | fab auth.pro cisco.xxxx
$ ssh user01@xx.xx.xx.xx show version
$FHHOME/fabfile/cisco.py
import sys, os from fabric.api import * from fabric.contrib import files env.eagerly_disconnect = False FHHOME=os.environ["FHHOME"] #================================================================================ # common #================================================================================ #------------------------------------------------------------------ # cisco.enable #------------------------------------------------------------------ @task def enable(): try: run("enable", shell=False) except Exception as e: print e #------------------------------------------------------------------ #cisco.term_leng0 #------------------------------------------------------------------ @task @runs_once def termlen0(): """ terminal length 0 """ run("terminal length 0", shell=False) #------------------------------------------------------------------ #cisco.sh_run #------------------------------------------------------------------ @task def sh_run(): """show runnning-config""" run("show running-config", shell=False) #------------------------------------------------------------------ #cisco.sh_int_status #------------------------------------------------------------------ @task def sh_int_status(): """show interfaces status""" run("show interfaces status", shell=False)