Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement