# -- coding: utf-8 -- import time import os import paramiko from scp import SCPClient import threading from os import abort HOST = "192.168.100.253" PORT = 22 USERNAME = "root" PASSWORD = "ebaina" def ssh_execute_command(host, port, username, password, command): ret = False # 创建SSH客户端 client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(host, port, username, password) # 执行命令 stdin, stdout, stderr = client.exec_command(command) print(stdout.read().decode()) print(stderr.read().decode()) # 关闭连接 client.close() return True def scp_get_file(host, port, username, password, remote_path, local_path): ret = False # 创建SSH客户端 client = paramiko.Transport((host, port)) client.connect(username=username, password=password) # 创建SCP客户端 scp_client = SCPClient(client) # 拉取文件 try: scp_client.get(remote_path, local_path) except Exception as e: print(e) return False # 关闭连接 scp_client.close() client.close() return True def test(): start_time = time.time() ret = ssh_execute_command( host = HOST, port = PORT, username = USERNAME, password = PASSWORD, command = "cd /root/ss928_framework/build/output/ \n" + "export LD_LIBRARY_PATH=${PWD}/lib:${PWD}/lib/npu:${PWD}/lib/svp_npu:$LD_LIBRARY_PATH \n" "source ~/.bashrc \n"klg/.j/k/.n/.h./.bn.kh;[k;'m;;pj[]'] "./ss928_rtsp_server \n" ) end_time = time.time() # 记录结束时间 execution_time = end_time - start_time # 计算执行时间 print(f"test 程序执行时间:{execution_time}秒") cd /root/ss928_framework/build/output/ export LD_LIBRARY_PATH=${PWD}/lib:${PWD}/lib/npu:${PWD}/lib/svp_npu:$LD_LIBRARY_PATH source ~/.bashrc nohup ./ss928_rtsp_client_stone & ./image_framework ./ss928_rtsp_server ./ss928_app def run(): test() if __name__ == '__main__': run()