Not able to navigate to desired folder on remote Linux machine, how do i do that using paramiko?

后端 未结 2 1675
余生分开走
余生分开走 2020-12-22 05:40

I am Using Pyhton paramiko and My website server has folder structure like this-

1]dir1
      --dirP
      --dirQ
2]dir2
      --dirA
          --file.sh
            


        
相关标签:
2条回答
  • 2020-12-22 06:12

    Or if you use variables need to add + for example

    client.exec_command('str(var1)+str(var2))
    
    0 讨论(0)
  • 2020-12-22 06:29

    client.exec_command("cmd ...") is just like the command ssh user@host "cmd ..." so

    client.exec_command('cd dir2')
    client.exec_command('ls')
    

    are just like

    ssh user@host 'cd dir2' # this would not affect the following `ls'
    ssh user@host 'ls'
    

    . So you need to do like this:

    client.exec_command('cd dir2; ls')
    

    which is just like

    ssh user@host 'cd dir2; ls'
    
    0 讨论(0)
提交回复
热议问题