From: Peter Bailey Date: 2006-05-04T05:25:26+09:00 Subject: Re: problems ftp'ing with RUBY Daniel Harple wrote: > On May 3, 2006, at 5:19 PM, Peter Bailey wrote: > >> require 'net/ftp' >> indexfiles = Dir.glob("*.pdf") >> indexfiles.each do |indexfile| >> ftp = Net::FTP.open('mpc.bna.com') do |ftp| >> ftp.login('username','password') >> ftp.chdir('/data/bnaindex') >> ftp.putbinaryfile("indexfile") > ^^^^^^^^^ > you want indexfile, not "indexfile" >> end >> end > > Also, you are creating a new connection for every file. You want > something like: > > require 'net/ftp' > Net::FTP.open('mpc.bna.com') do |ftp| > ftp.login('username','password') > ftp.chdir('/data/bnaindex') > Dir.glob("*.pdf").each { |file| ftp.putbinaryfile(file) } > end > > -- Daniel Thanks. I'll try this. The reason I was doing it for every file was because, in my real, live file, I'm sending a notification e-mail for each file sent, with the filename in the subject line. I suppose I could still do that, after sending all the files en-masse. Just to a mail "each" for each PDF. -- Posted via http://www.ruby-forum.com/.