Guest User

Untitled

a guest
Feb 28th, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.15 KB | None | 0 0
  1. #!/usr/bin/ruby ruby
  2. require 'net/ftp'
  3. ftp=Net::FTP.new
  4.  
  5. def conn
  6.     puts ("What is the address of the desired FTP server?")
  7.     ftpaddr=gets.chomp
  8.     puts ("On what port would you like to connect? *Default is 21*")
  9.     port=gets.chomp.to_i
  10.     ftp.connect(ftpaddr,port)
  11. end
  12.  
  13. def login
  14.     puts ("What usernam would you like to login with?")
  15.     user=gets.chomp
  16.     puts ("Enter Password:")
  17.     pass=gets.chomp
  18.     ftp.login(user,pass)
  19. end
  20.  
  21. def dirchg
  22.     ftp.list
  23.     puts ("What directory would you like to navigate to?")
  24.     dir=gets.chomp
  25.     ftp.chdir(dir)
  26.     choice
  27. end
  28.  
  29. def getfile
  30.     ftp.list
  31.     puts ("What file would you like to download?")
  32.     file=gets.chomp
  33.     puts ("What local director would you like to save the file to?")
  34.     localdir=gets.chomp
  35.     ftp.getbinaryfile(file,localdir,1024)
  36.     choice
  37. end
  38.  
  39. def choice
  40.     puts ("What would you like to do?\nCHDIR\nGETFILE\nHOME\nEXIT")
  41.     input=gets.chomp
  42.     case input
  43.     when "CHDIR"
  44.         dirchg
  45.     when "GETFILE"
  46.         getfile
  47.     when "HOME"
  48.         ftp.chdir("/")
  49.         choice
  50.     when "EXIT"
  51.         ftp.close
  52.     else
  53.         puts ("Please choose one of the 4 choices!")
  54.         choice
  55.     end
  56. end
  57.  
  58. conn
  59. login
  60. puts ("Succesfully connected to #{addr}!")
  61. ftp.list
  62. choice
Advertisement
Add Comment
Please, Sign In to add comment