Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby ruby
- require 'net/ftp'
- ftp=Net::FTP.new
- def conn
- puts ("What is the address of the desired FTP server?")
- ftpaddr=gets.chomp
- puts ("On what port would you like to connect? *Default is 21*")
- port=gets.chomp.to_i
- ftp.connect(ftpaddr,port)
- end
- def login
- puts ("What usernam would you like to login with?")
- user=gets.chomp
- puts ("Enter Password:")
- pass=gets.chomp
- ftp.login(user,pass)
- end
- def dirchg
- ftp.list
- puts ("What directory would you like to navigate to?")
- dir=gets.chomp
- ftp.chdir(dir)
- choice
- end
- def getfile
- ftp.list
- puts ("What file would you like to download?")
- file=gets.chomp
- puts ("What local director would you like to save the file to?")
- localdir=gets.chomp
- ftp.getbinaryfile(file,localdir,1024)
- choice
- end
- def choice
- puts ("What would you like to do?\nCHDIR\nGETFILE\nHOME\nEXIT")
- input=gets.chomp
- case input
- when "CHDIR"
- dirchg
- when "GETFILE"
- getfile
- when "HOME"
- ftp.chdir("/")
- choice
- when "EXIT"
- ftp.close
- else
- puts ("Please choose one of the 4 choices!")
- choice
- end
- end
- conn
- login
- puts ("Succesfully connected to #{addr}!")
- ftp.list
- choice
Advertisement
Add Comment
Please, Sign In to add comment