From: Brian Candler Date: 2012-09-10T05:02:08+09:00 Subject: Re: Need help with my logic sharmin malik wrote in post #1075228: > but i dont know ,how will i know from which server i am running require 'socket' myname = Socket.gethostname > and how > to get hostname of the rest 2 servers. I guess the easiest way is to make the names of all three, and remove the one you don't want (i.e. your own) require 'socket' myname = Socket.gethostname unless myname =~ /\A(\w+-v)([khv])(-\d+\..+)\z/ raise "Bad hostname format: #{myname.inspect}" end hosts = [$1+"k"+$3, $1+"h"+$3, $1+"v"+$3] unless hosts.delete myname raise "Can't find my hostname #{myname.inspect} to remove from #{hosts.inspect}" end hosts.each do |host| puts "Please connect to #{host}" end -- Posted via http://www.ruby-forum.com/.