Created
January 16, 2012 05:39
-
-
Save weirdbricks/1619237 to your computer and use it in GitHub Desktop.
upload to ftp/tls
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
this will upload a file on ftp using TLS: | |
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'ftpfxp' #required for FTP/TLS | |
require 'ptools' #required to tell if a file is text or binary | |
puts 'Connecting...' | |
HOST='192.168.2.12' | |
USER='ftptest2' | |
PASS='ftptest2' | |
FILE='/myfile.dat' | |
ftp = Net::FTPFXPTLS.new | |
ftp.passive=true | |
ftp.debug_mode=true | |
ftp.connect(HOST,21) | |
ftp.login(USER,PASS) | |
if (File.binary?(FILE)) #this will check if the file is binary or not and will print a message | |
puts "file is binary" | |
else | |
puts "file is not binary" | |
end | |
ftp.putbinaryfile(FILE,FILE) #right now all files are uploaded as binaries, this is easy to change | |
ftp.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment