net::FTP fails me (newbe question)

Discussion in 'Ruby' started by Bill Mustard, Oct 16, 2005.

  1. Bill Mustard

    Bill Mustard Guest

    I am running ruby 1.8.2 (2004-12-25) [i386-mswin32] on winXp SP2+ and
    using ruby to do a bunch of website formatting maintenance and general
    tidying up. The last step is to send the changed files to the site.
    All of the files end up truncated! the code bloc I am using is: (names
    and places changed to protect the innocent)

    if changed != {}
    print "Send to web site? [Y,n]"
    a = $stdin.gets.chomp
    if a =~ /^y.*/i || a == ''
    ftp = Net::FTP.new('website.place')
    ftp.login('name','password')
    ftp.chdir('www/fileplace')
    changed.each_key {|f|
    print f
    ftp.puttextfile(f)
    puts ": " + ftp.size(f).to_s + " of #{changed[f]}"
    }
    ftp.close
    end
    end

    Any help is appreciated.

    Thanks in advance.

    Bill Mustard
     
    Bill Mustard, Oct 16, 2005
    #1
    1. Advertising

  2. Bill Mustard

    Guest

    Re: net::FTP fails me (newbe question)(further)

    Bill Mustard wrote:
    > I am running ruby 1.8.2 (2004-12-25) [i386-mswin32] on winXp SP2+ and
    > using ruby to do a bunch of website formatting maintenance and general
    > tidying up. The last step is to send the changed files to the site.
    > All of the files end up truncated! the code bloc I am using is: (names
    > and places changed to protect the innocent)
    >
    > if changed != {}
    > print "Send to web site? [Y,n]"
    > a = $stdin.gets.chomp
    > if a =~ /^y.*/i || a == ''
    > ftp = Net::FTP.new('website.place')
    > ftp.login('name','password')
    > ftp.chdir('www/fileplace')
    > changed.each_key {|f|
    > print f
    > ftp.puttextfile(f)
    > puts ": " + ftp.size(f).to_s + " of #{changed[f]}"
    > }
    > ftp.close
    > end
    > end
    >
    > Any help is appreciated.
    >
    > Thanks in advance.
    >
    > Bill Mustard


    I changed "ftp.puttextfile(f)" to "ftp.putbinaryfile(f,f,1024)"
    even though they are text files, and the transfer works!

    Thanks
    Bill
     
    , Oct 16, 2005
    #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. Replies:
    3
    Views:
    5,647
  2. Nico Grubert
    Replies:
    0
    Views:
    645
    Nico Grubert
    Nov 24, 2005
  3. Nico Grubert
    Replies:
    0
    Views:
    447
    Nico Grubert
    Nov 25, 2005
  4. Vin Raja

    FTP : Time problem (net/ftp)

    Vin Raja, Jun 7, 2007, in forum: Ruby
    Replies:
    0
    Views:
    102
    Vin Raja
    Jun 7, 2007
  5. D. Buck
    Replies:
    2
    Views:
    489
    D. Buck
    Jun 29, 2004
Loading...

Share This Page