Just change: Net::Ping::TCP.new('loocaalhost') to: Net::Ping::TCP.new(loocaalhost) And you might want to consider a different spelling of "loocaalhost" as well, but you don't want to quote your variable. From my iPhone --- Pat On Oct 3, 2011, at 11:49 AM, Edward QU <ajax.htm / gmail.com> wrote: > Dear All > I am just want to write a program to ping my servers if them are alive, > using Ruby, but it doesnt work, whatever the ip address I put down in > the programe, it all said ok, any advise would be great appricated. > > my PC os is windows7 64digital > ------------------------------------------- > require 'net/ping' > include Net > > Ping::TCP.service_check = true > > loocaalhost="192.168.1.555" > > if Net::Ping::TCP.new('loocaalhost') > puts 'TCP OK' > else > puts 'NO respons' > end > > if Net::Ping::External.new('loccalhost') > puts 'Exteranl OK' > else > puts 'NO respons' > end > > --------------- > TCP OK > Exteranl OK > > -- > Posted via http://www.ruby-forum.com/. >