-
-
Save anonymous/73e1e5b2b863a0726a5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_remote_files(environment, hostname, directory_list, ignore_list) | |
counter = 0 | |
Net::SSH.start(hostname, USERNAME, :password => PASSWORD) do |ssh| | |
directory_list.each do |dir| | |
ssh.exec("find #{dir} -type d -o -type f -exec stat -c '%u, %g, %a, %s, %Y, %n' {} \\;") do |ch, stream, data| | |
# User ID, Group ID, Access Rights (octal), Total Size (bytes), Last Modified Time (unix timestamp) | |
data_array = data.split(", ") | |
file_path = "#{data_array[5]}".gsub("\n", "") | |
unless ignore_list.any? { |s| file_path.include?(s) } then | |
hash = "#{file_path}#{data_array[0]}#{data_array[1]}#{data_array[2]}#{data_array[3]}#{data_array[4]}".hash | |
hash_file(environment, file_path, data_array[0], data_array[1], data_array[2], data_array[3], data_array[4], hash) | |
#puts "#{hash}, #{dir}, #{data_array[5]}" | |
#counter += 1 | |
end | |
counter += 1 | |
end | |
#ssh.loop | |
end | |
end | |
puts "Finished processing #{counter} remote files on #{hostname}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment