所以我需要能够检查一个盒子上的软件版本,我找到了一个目录,并试图ssh到它。 到目前为止,我可以成功地进入盒子并进入dir(我认为)如何在该目录的一侧打印所有内容。 这是我的代码
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")So i need to be able to check version of software on a box, i found a directory where it would be and am trying to ssh into it. So far i can ssh successfully into the box and cd into the dir (i think) how do i print everything in side of that dir. Here is my code
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标志将列出所有文件,包括目录中符号链接的文件。 不幸的是,其他linux命令如find . , ls -R等在符号链接处停止,而不导航到它们中以进一步列出。
请让我知道,如果你有任何问题!
Try this:
stdin,stdout,stderr = ssh.exec_command("PATH='path' && cd/mnt/soft; ls -LR > contents.txt; cat VERSION")The -L flag will list all files including the ones in the directories which are symlinks. Unfortunately, other linux commands such as find ., ls -R, etc stop at the symlink without navigating into them to list further.
Please let me know if you have any questions!
打印ssh目录python中的所有内容(Printing everything inside of ssh directory python)所以我需要能够检查一个盒子上的软件版本,我找到了一个目录,并试图ssh到它。 到目前为止,我可以成功地进入盒子并进入dir(我认为)如何在该目录的一侧打印所有内容。 这是我的代码
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")So i need to be able to check version of software on a box, i found a directory where it would be and am trying to ssh into it. So far i can ssh successfully into the box and cd into the dir (i think) how do i print everything in side of that dir. Here is my code
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标志将列出所有文件,包括目录中符号链接的文件。 不幸的是,其他linux命令如find . , ls -R等在符号链接处停止,而不导航到它们中以进一步列出。
请让我知道,如果你有任何问题!
Try this:
stdin,stdout,stderr = ssh.exec_command("PATH='path' && cd/mnt/soft; ls -LR > contents.txt; cat VERSION")The -L flag will list all files including the ones in the directories which are symlinks. Unfortunately, other linux commands such as find ., ls -R, etc stop at the symlink without navigating into them to list further.
Please let me know if you have any questions!
发布评论