Ip ftp

The idea of this script is:

  1. Download ftp file.
  2. Mail to some user (have not done that yet (yes this is essentially
    my first script)

I am trying to incorporate some error handling so the script needs

  1. To test if machine has Internet connection
  2. check if ip is connectected.

This is where i fail to understand why this does not work. The script
essentially just times out

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/ftp.rb:159:in
`initialize’: Operation timed out - connect(2) (Errno::ETIMEDOUT)

in the terminal i get under 1 sec response times.

Thank you in advance

if Ping.pingecho(ipMainAddress, 2) == true then
ipAddress = ipMainAddress
elsif Ping.pingecho(ipBackUpAddress, 2) == true then
ipAddress = ipBackUpAddress
else
puts "Check the following 3 things: "
end

ftp = Net::FTP.new(ipAddress)

ftp.login(userId, passWord)

ftp.getbinaryfile(fileName)

ftp.close