python

Login ssh automation

import sys
import pyperclip
import subprocess

if len(sys.argv) == 1:
    print('login func needs client to login...')
elif sys.argv[1] == 'do':
    print('login at do, use paste')
    cb = pyperclip.copy('Password')
    bashCommand = "echo apt update"
    subprocess.call(["ssh", "user@ip.address.0.0"])
else:
    print('No login available for '+ sys.argv[1])

sys.exit(1)

adjust zshrc in

~/.zshrc add location python3 and filelocation

alias li="/Users/hjhubeek/Documents/development/python/li/bin/python /Users/hjhubeek/Documents/development/python/li/li.py"

json call rest

import urllib, json
>>> url = "http://maps.googleapis.com/maps/api/geocode/json?address=googleplex&sens..."
>>> url = "http://myexternalip.com/json"
>>> response = urllib.urlopen(url);
>>> data = json.loads(response.read())
>>> print data
{u'ip': u'80.57.121.251'}

Tags: 
Subscribe to RSS - python