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. Advertisements

  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. Advertisements

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:
    6,596
  2. Nico Grubert
    Replies:
    0
    Views:
    880
    Nico Grubert
    Nov 24, 2005
  3. Daniel Berger

    net/ftp works manually, fails via cron

    Daniel Berger, Sep 23, 2005, in forum: Ruby
    Replies:
    3
    Views:
    210
    Daniel Berger
    Sep 23, 2005
  4. Vin Raja

    FTP : Time problem (net/ftp)

    Vin Raja, Jun 7, 2007, in forum: Ruby
    Replies:
    0
    Views:
    242
    Vin Raja
    Jun 7, 2007
  5. Ari Brown

    Net::FTP and ftp.dir()

    Ari Brown, Jul 16, 2007, in forum: Ruby
    Replies:
    0
    Views:
    201
    Ari Brown
    Jul 16, 2007
  6. Jeff Miller
    Replies:
    0
    Views:
    913
    Jeff Miller
    Mar 26, 2009
  7. D. Buck
    Replies:
    2
    Views:
    974
    D. Buck
    Jun 29, 2004
  8. bala

    ftp nmap support in Net::FTP

    bala, Mar 25, 2005, in forum: Perl Misc
    Replies:
    6
    Views:
    236
    Matija Papec
    Mar 29, 2005
Loading...