通过 paramiko 到嵌入式操作系统 QNX Neutrino 的 SSH 连接命令

问题描述

我正在尝试与 QNX neutrino OS 设备建立 SSH 连接,并运行位于 ls 目录中的文件“shutdownDevice”和“startupDevice”。我可以通过 PuTTY 做到这一点,没有任何问题。我下面的代码没有输出任何错误并成功完成,但文件“shutdownDevice”和“startupDevice”实际上并没有像通过 PuTTY SSH 连接那样重启设备。可能很简单,我是新手!

def deviceblahblah():
        # Connect to inputed host through a SSH connection
        client = SSHClient()
        # No ssh host keys,add host keys with auto add policy
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        host = (IPText.get())
        client.connect(host,username='xx',password='xx')
        #Connection Sucessful information
        print("SSH Connection Successful")
        #Stop the device
        stdin,stdout,stderr = client.exec_command('shutdownDevice')
        #Wait 5 seconds
        time.sleep(5)
        #Start the device
        stdin,stderr = client.exec_command('startupDevice')
        # Close the client connection    
        client.close()
        print("Connection Closed")

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)