Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<code>
require "net/ssh"
require 'net/ssh/shell'
require 'capistrano/rails'
require 'sshkit'
require 'sshkit/dsl'
include SSHKit::DSL

@hostname = "lwa1001.env-10-100-222.iagcloud"
@username = "admin"
@password = "password1"
@cmd = "ls -la"
res = ""
ssh = Net::SSH.start(@hostname, @username, :password => @password) do |ssh|
ssh.shell do |sh|

    path="/cguclaim/virtual/data/logs/gwlogs/ClaimCenter/"
    path="/claims_virt/inout/"
    require 'pry'; binding.pry;

  res = ssh.exec! (@cmd) do |channel, stream, data|
  Dir.chdir('/destination_directory')
  Dir.glob('*').select {|f| File.directory? f}
  end

    puts res
  rescue
    puts "Unable to connect to #{@hostname} using #{@username}/#{@password}"
  end


  # res = ssh.exec!(@cmd)
  # if Dir.exist?(path) && File.directory?(path)
  #     puts "Directory exists"
  # else
  #     puts "Directory not found"
  # end


What I have tried:

Trying to work out here what I am doing wrong since the two folder paths are not able to be connected. Is there a better way also of doing this from remote to local server?
Posted
Comments
ZurdoDev 11-Sep-18 8:09am    
What is the error?
mcne65 11-Sep-18 22:09pm    
It's not working from remote to local host block - I need to find the right way how to find this

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900