lvjian700
1/15/2013 - 9:31 AM

Ruby connect to FTP

Ruby connect to FTP

require "net/ftp"

host = "ftp://192.168.1.42/"
begin
21ftp = Net::FTP.new
	ftp.connect('192.168.1.42', 21)
	ftp.login('***', '***')
	status = ftp.status
	#p status
	files = ftp.list('*')
	p files
	
	#ftp.put('maven-jar-plugin-2.3.1.jar', 'maven.jar')
#	ftp.mkdir('test')
rescue Exception => ex
	puts ex
ensure
	ftp.close
end