Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save carld/392045 to your computer and use it in GitHub Desktop.
Save carld/392045 to your computer and use it in GitHub Desktop.
ftp = Net::FTP::new(site)
ftp.login(user, password)
y_combinator {|callback|
lambda {|entry|
if FileTest.directory?(entry)
entries = ftp.nlst
ftp.mkdir(File.basename(entry)) unless entries.include?(File.basename(entry))
ftp.chdir(File.basename(entry))
puts 'cd ' + File.basename(entry)
Dir[entry + '/*'].each {|e| callback.call(e)}
ftp.chdir('..')
puts 'cd ..'
else
puts entry + ' --> ' + File.basename(entry)
ftp.putbinaryfile(entry, File.basename(entry))
end
}
}.call('public_html')
ftp.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment