T
Tim Wolak
Can someone explain why my code is stopping after looking at the first
file? There are at least 20 files in this directory and it stops after
checking just one.
require 'net/ftp'
class Download
ftp = Net::FTP.new('ftp.site.com')
ftp.login(user="user", passwd="123")
file = ftp.nlst
file.each do | list |
last = "20080609"
curdate = Time.now.localtime.strftime("%Y%m%d")
yesterday = Time.now - 86400
prevday = yesterday.strftime("%Y%m%d")
t = Time.now
hour = t.hour
if(hour >= 0)
procFile = prevday
elsif(hour < 23)
procFile = curdate
end
#procFile = 20080613
lastProc = last
list.scan(/\d{8}/) do | t |
p [t, procFile, list]
if(t == procFile && list =~ /FutBal\d{8}.txt/)
Dir.chdir("/tmp")
ftp.gettextfile(list, localfile = File.basename(list))
exit
elsif(t != procFile && list !~ /FutBal#{procFile}.txt/)
sleep(1800)
end
end
end
end
file? There are at least 20 files in this directory and it stops after
checking just one.
require 'net/ftp'
class Download
ftp = Net::FTP.new('ftp.site.com')
ftp.login(user="user", passwd="123")
file = ftp.nlst
file.each do | list |
last = "20080609"
curdate = Time.now.localtime.strftime("%Y%m%d")
yesterday = Time.now - 86400
prevday = yesterday.strftime("%Y%m%d")
t = Time.now
hour = t.hour
if(hour >= 0)
procFile = prevday
elsif(hour < 23)
procFile = curdate
end
#procFile = 20080613
lastProc = last
list.scan(/\d{8}/) do | t |
p [t, procFile, list]
if(t == procFile && list =~ /FutBal\d{8}.txt/)
Dir.chdir("/tmp")
ftp.gettextfile(list, localfile = File.basename(list))
exit
elsif(t != procFile && list !~ /FutBal#{procFile}.txt/)
sleep(1800)
end
end
end
end