Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
打印ssh目录python中的所有内容_Python_Ssh - Fatal编程技术网

打印ssh目录python中的所有内容

打印ssh目录python中的所有内容,python,ssh,Python,Ssh,所以我需要能够在一个盒子上检查软件的版本,我找到了一个目录,它将在那里,我正在尝试ssh到它。到目前为止,我可以成功地ssh到盒子中,并将cd刻录到目录中。我想我该如何在该目录的一侧打印所有内容。这是我的密码 def CheckVersion(ThreadIP,ThreadPw,port,ThreadUser): ssh = createSSHClient(ThreadIP,ThreadPw,port,ThreadUser) if ssh == 0:

所以我需要能够在一个盒子上检查软件的版本,我找到了一个目录,它将在那里,我正在尝试ssh到它。到目前为止,我可以成功地ssh到盒子中,并将cd刻录到目录中。我想我该如何在该目录的一侧打印所有内容。这是我的密码

 def CheckVersion(ThreadIP,ThreadPw,port,ThreadUser):
      ssh = createSSHClient(ThreadIP,ThreadPw,port,ThreadUser)
      if ssh == 0:
          print "oh crap I just returned 0"
      else:
          stdin,stdout,stderr =  ssh.exec_command("PATH='path' && cd/mnt/soft; cat VERSION")
试试这个:

 stdin,stdout,stderr =  ssh.exec_command("PATH='path' && cd/mnt/soft; ls -LR > contents.txt; cat VERSION")
L标志将列出所有文件,包括目录中的符号链接文件。不幸的是,find、、ls-R等其他linux命令在符号链接处停止,而没有导航到它们以进一步列出


如果您有任何问题,请告诉我content.txt,也可以通过终端对其进行ssh,运行ls-LR并在终端上查看是否生成了内容,命令是否按预期运行。你能做这两件事并告诉我发生了什么吗0此外,您可能需要检查是否需要转义字符串。还要知道,它将在您使用ssh连接到的机器上生成字符串!如果您有任何问题,请告诉我!