-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsftp_timing.py
More file actions
executable file
·55 lines (45 loc) · 1.09 KB
/
Copy pathsftp_timing.py
File metadata and controls
executable file
·55 lines (45 loc) · 1.09 KB
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
51
52
53
54
55
#!/usr/bin/python3
import paramiko
import time
import sys
# usage: ./test_sftp.py user password host
# to deal with empty passwords
class MainClass():
def ls_file_index(self):
pass
def start(self):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
if len(sys.argv) == 3:
arg1 = sys.argv[1]
arg2 = ''
arg3 = sys.argv[2]
arg4 = 22
try:
ssh.connect(arg3,int(arg4),arg1,arg2)
except:
ssh.connect(arg3,int(arg4),arg1,arg2,allow_agent=False,look_for_keys=False)
else:
arg1 = sys.argv[1]
arg2 = sys.argv[2]
arg3 = sys.argv[3]
try:
arg4 = sys.argv[4]
except:
arg4 = 22
ssh.connect(arg3,int(arg4),arg1,arg2,allow_agent=False,look_for_keys=False)
sftp = ssh.open_sftp()
try:
# they aren't sorted, but they have the same order anyway
dir_attr = sftp.listdir_attr()
dir_fils = sftp.listdir()
for index in range(len(dir_attr)):
attr = dir_attr[index]
print(attr.__str__())
print(dir_fils[index])
finally:
sftp.close()
ssh.close()
if __name__ == "__main__":
a = MainClass()
a.start()