-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyssh.py
50 lines (34 loc) · 952 Bytes
/
pyssh.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import paramiko
from guietta import _, Gui, Quit
from os import getcwd
#everything in uppercase is for configuration and therefore should be changed
host = 'HOSTNAME'
port = HOSTPORT
username = 'USERNAME'
password = 'PASSWORD'
def ssh_connection():
global ssh
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, port, username, password)
def command(command):
global stdin, stdout, stderr
stdin, stdout, stderr = ssh.exec_command(command)
def sftp_connection():
global sftp
sftp = ssh.open_sftp()
if(__name__ == '__main__'):
ssh_connection()
gui = Gui(
[ 'Command: ', '__command__' ,['Run'] ],
[ 'Result: ' , 'result' , _ ],
[ _ , ['Copy'] , Quit ]
)
with gui.Copy:
sftp_connection()
sftp.get(gui.command, getcwd() + '\\copy.txt')
sftp.close()
with gui.Run:
command(gui.command)
gui.result = stdout.readlines()
gui.run()