copy remote a file

Discussion in 'Ruby' started by Bu Mihai, Sep 30, 2008.

  1. Bu Mihai

    Bu Mihai Guest

    How can i copy with ruby a file from my computer to another computer
    from lan? I have the administrator password of that computer.
    Bu Mihai, Sep 30, 2008
    1. Advertisements

  2. If the way you login to the other computer is with ssh, then I'd suggest
    using Net::SFTP (available as a gem)
    Brian Candler, Sep 30, 2008
    1. Advertisements

  3. Bu Mihai

    Dick Davies Guest

    If it's UNIX/Linux, use scp . If it's Windows, expect you can use file shares
    (or just stick it on a webserver and pull it down with a browser).
    Dick Davies, Sep 30, 2008
  4. Bu Mihai

    Bu Mihai Guest

    i have this problem with net::sftp:
    require 'net/ssh'
    require 'net/sftp'
    session = Net::SSH.start("machine1","administrator","baubau")

    I have this error:
    `start': undefined method `keys' for "baubau":String (NoMethodError)
    from connect.rb:10

    The machine1 is up and the password is a valid one.
    Bu Mihai, Sep 30, 2008
  5. Bu Mihai

    Todd Benson Guest

    According to the docs for SSH (and also SFTP), the third parameter
    should be a Hash...

    session = Net::SSH.start("machine1", "administrator", :password => "baubau")

    ...or for SFTP...

    session = Net::SFTP.start("machine1", "administrator", :password => "baubau")

    Try it outside of ruby first (in unix shell)...
    Todd Benson, Sep 30, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.