Links
  • Documentation
  • Download
  • Project Page
  • License
  • Net::Netrc for Ruby

    Net::Netrc is a pure-Ruby module providing ftp(1)-style .netrc parsing. It is inspired by Graham Barr’s Perl Net::Netrc module. It has been tested on Unix and Windows systems, but should work on other platforms where Ruby is available.

    Net::Netrc also provides an optional extension to the standard Net::FTP module to perform auto-logins using the .netrc file.

    Net::Netrc is available as a Ruby Gem, so RubyGems users can install it with:

    gem install net-netrc

    If you wish to install the module manually, you may Download it in a variety of formats.

    Example Usage

    Standalone usage:

    require 'net/netrc'
    rc = Net::Netrc.locate('ftp.example.com') or
      raise ".netrc missing or no entry found" 
    puts rc.login
    puts rc.password
    puts rc.name

    Net::FTP auto-login:

    require 'net/ftp-netrc'
    ftp = Net::FTP.new('ftp.example.com')
    ftp.login(nil)          # nil username triggers Net::Netrc lookup
    puts ftp.last_response
    => 230 User myuser logged in.

    created with
    Rote