Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'net/ftp'
- require 'rubygems'
- require 'highline/import'
- hostname = ask('Enter the hostname of the remote computer: ')
- uname = ask('Enter the username for the remote computer: ')
- pass = ask('Enter the password associated with the username: '){|p| p.echo = "*" }
- $ftp = Net::FTP.new
- $ftp.passive = true
- puts "\nConnecting to "+hostname+"..."
- $ftp.connect hostname
- $ftp.login uname, pass
- choice = ask('Do you want to send or retrieve a file? (S/R)')
- def sendfile
- filename = ask('Enter the full path of the file you wish to send: ')
- rfilename = ask('Enter the directory and filename where this file should be placed: ')
- puts "Sending file..."
- $ftp.puttextfile filename, rfilename
- puts "File successfully sent."
- end
- def getfile
- filename = ask('Enter the path of the file you wish to retrieve: ')
- puts 'Downloading file...'
- $ftp.gettextfile filename
- puts 'File successfully downloaded.'
- end
- if choice.downcase == 's'
- sendfile
- else
- getfile
- end
- $ftp.close
Add Comment
Please, Sign In to add comment