Browse Source

Initial creation of python script that runs a SSH connection

pull/1/head
Jeffery Russell 7 years ago
commit
da2dbe75c1
1 changed files with 37 additions and 0 deletions
  1. +37
    -0
      src/ssh_manager.py

+ 37
- 0
src/ssh_manager.py View File

@ -0,0 +1,37 @@
"""
Jeffery Russell
9-26-17
"""
import subprocess
import collections
INPUT_FILE = "/home/jeff/scripts/servers.txt"
Computer = collections.namedtuple("Computer", ('host', 'menue_id'))
def main():
cmp = []
count = 1
with open(INPUT_FILE) as file:
for line in file:
cmp.append(Computer(line, count))
count += 1
print("SSH manager V 0.1")
for c in cmp:
print(str(c.menue_id) + ")", c.host)
print()
i = input("Enter number of computer to connect to or enter to exit:")
for c in cmp:
if i != '' and int(i) == c.menue_id:
subprocess.call(["ssh", c.host.strip(' \t\n\r')])
#subprocess.Popen("ssh " + c.host.strip(' \t\n\r'))
"""
Makes sure that this other programs don't run the program
"""
if __name__ == '__main__':
main()

Loading…
Cancel
Save