How can i execute 2 or more commands in the same ssh session?

前端 未结 7 1348
南方客
南方客 2021-01-06 01:14

I have the following script:

#!/usr/bin/env ruby
require \'rubygems\'
require \'net/ssh\'

Net::SSH.start(\'host1\', \'root\', :password => \"mypassword1\         


        
7条回答
  •  再見小時候
    2021-01-06 01:38

    ssh.exec("cd /var/example/engines/; pwd")
    

    That will execute the cd command, then the pwd command in the new directory.

    I'm not a ruby guy, but I'm going to guess there are probably more elegant solutions.

提交回复
热议问题