NET::SFTP downloading multiple directories.

Discussion in 'Ruby' started by Chris Brand, Jun 1, 2008.

  1. Chris Brand

    Chris Brand Guest

    Hi guys,

    Im pretty new to ruby, and I want to re-write a bash script I wrote to
    backup some data on an iphone to a local comp, in ruby.

    This is the bash version: http://pastebin.com/m1a34a96

    Here is what i have in ruby so far: http://pastebin.com/m1c2282c0

    What I basically want to do is have an array of remote directories
    downloaded via stfp to a local folder in a loop, or something to this
    effect, and I cant seem to figure it out...

    Any help is greatly appreciated!!

    -Chris
    --
    Posted via http://www.ruby-forum.com/.
     
    Chris Brand, Jun 1, 2008
    #1
    1. Advertising

  2. Chris Brand

    Chris Brand Guest

    Ok so I got a little further with this, but its still not working
    perfectly... I think the wait method is screwing things up, because I
    only get the contents of the first folder.

    #!/usr/bin/env ruby

    require 'FileUtils'
    require 'net/sftp'

    $local_dir = '/iBak' + Time.now.strftime("%m_%d_%y")
    $user_name = 'root'
    $backup_dirs = ['/Applications',
    '/var/root/Library/Customize2',
    '/var/mobile/Library/Installer',
    '/var/mobile/Media/EBooks',
    '/var/preferences'
    ]
    puts "Please enter your iPhones IP address:"
    $phone_ip = gets.chomp!
    puts "Now your password:"
    $root_pass = gets.chomp!
    puts "\nPress enter to begin..."
    gets

    FileUtils.mkdir_p $local_dir

    Net::SFTP.start( $phone_ip, $user_name, :password => $root_pass ) do
    |backup|
    dls = $backup_dirs.map { |f| backup.download!( f, $local_dir,
    :recursive => true) }
    dls.each do |d|
    d.wait
    end
    end

    Again, any help would be great!

    -Chris
    --
    Posted via http://www.ruby-forum.com/.
     
    Chris Brand, Jun 1, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TGFzc2UgTmlsc3Nvbg==?=

    Multiple bin-directories with virtual directories?

    =?Utf-8?B?TGFzc2UgTmlsc3Nvbg==?=, Nov 9, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    841
    =?Utf-8?B?TGFzc2UgTmlsc3Nvbg==?=
    Nov 9, 2004
  2. Ruby Rails
    Replies:
    0
    Views:
    125
    Ruby Rails
    Apr 28, 2009
  3. Replies:
    3
    Views:
    165
    J. Gleixner
    Oct 22, 2007
  4. MaggotChild

    Net::SFTP Fails, sftp OK

    MaggotChild, Oct 28, 2009, in forum: Perl Misc
    Replies:
    2
    Views:
    1,035
    C.DeRykus
    Oct 29, 2009
  5. Kevin13
    Replies:
    3
    Views:
    977
    Kevin13
    Dec 1, 2009
Loading...

Share This Page