标签:info out 系统 ber option number ror == div
下载安装Ajaxterm
创建一个新用户
这里我建了一个ip.txt文件存放ip地址
su - HaojieMao
vi term__ssh.py
代码如下:
#! /usr/bin/env python import os ip_file = ‘ip.txt‘ ip_dic = {} num = 0 f = file(ip_file) while True: num += 1 line = f.readline() if len(line) == 0:break ip_dic[num] = line f.close() while True: try: for k,v in ip_dic.items(): print "%s. %s"%(k,v) option = int(raw_input(‘Please choose one server to connect:‘)) if option in ip_dic.keys(): print ip_dic[option] f = file(log_file,‘a‘) f.write("\n-------LOGIN INFO: connect to %s\n"%ip_dic[option]) f.close() user = raw_input(‘username:‘).strip() cmd = ‘ssh %s@%s‘ % (user,ip_dic[option]) os.system(cmd) else: print‘Number out of range!‘ except ValueError: print ‘Wrong‘
标签:info out 系统 ber option number ror == div
原文地址:http://www.cnblogs.com/xiaoxinzang/p/7290185.html