From 2575f862c054d6ea390db1e3251cbd093f45f0b9 Mon Sep 17 00:00:00 2001 From: vsadmin Date: Fri, 9 Oct 2026 08:48:10 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20pkg=5Finstal.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg_instal.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 pkg_instal.py diff --git a/pkg_instal.py b/pkg_instal.py new file mode 100644 index 0000000..10ad9e9 --- /dev/null +++ b/pkg_instal.py @@ -0,0 +1,50 @@ +import paramiko +import time + +port = 22 +username = 'root' +password = 'root' +sources = 'http://172.20.100.201:8000/iperf3.ipk' +subnets = "192.168.16." +#objects = [4, 9, 11, 35, 38, 40, 42, 44, 49, 51, 57, 58, 62, 63, 67, 68, 69, 76, 85] +objects = [78] +#objects = [4, 9, 11, 27, 28, 29, 30, 32, 34, 35, 38, 39, 41, 42, 43, 44, 49, 50, 55, 57, 58, 62, 65, 66, 67, 68, 69, 70, 76, 81, 82, 84] + +for i in objects: + + try: + # Создаем SSH-клиент + client = paramiko.SSHClient() + client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + hostip = subnets + str(i) + + # Подключение + client.connect(hostname=hostip, port=port, username=username, password=password) + print(hostip) + + # Выполнение команды + rem_conn = client.invoke_shell() + time.sleep(1) + rem_conn.send("wget " + sources + " -P /tmp/\n") + time.sleep(2) + rem_conn.send("opkg install /tmp/iperf3.ipk\n") + time.sleep(5) + rem_conn.send("rm /tmp/iperf3.ipk\n") + time.sleep(1) + rem_conn.send("opkg list-installed | grep iperf\n") + time.sleep(1) + rem_conn.close() + data = rem_conn.recv(1024) + print(data.decode()) + file = open(hostip + '_IRZ.txt', "a", newline='\n', encoding="utf-8") + file.write(data.decode()) + file.close() + client.close() + + + except TimeoutError: + text = 'Нет подключения ' + hostip + print(text) + file = open('down_no_conn.txt', "a", encoding="utf-8") + file.write(text + '\n') + file.close() \ No newline at end of file