[Email protected] ~]# cat/home/python/term_console.py
#!/usr/bin/env python
Import OS
Ip_file = ' Ip.txt '
Log_file = "/home/python/a.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
# Print Line
F.close ()
While True:
Try
For k,v in Ip_dic.items ():
# print "\033[32;%s.%s\033[0m"% (k,v),
Print "\033;%s.%s\033"% (k,v),
option = Int (raw_input (' plase 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 ()
# Pass = raw_input (' Password: '). Strip ()
cmd = ' ssh%[email protected]%s '% (User,ip_dic[option])
Os.system (CMD)
Else
print ' number out of range '.
Except ValueError:
print ' wrong value '
Python Springboard Machine Program