Check if remote server exists

Hello,
I’m developing an app that requires the user to define the name of a
Microsoft Exchange Server… I’d like to add functionality that checks
if the server exists. Is there a way to do this? Perhaps with win32ole?

Any help is appreciated!

Thanks,

  • Jeff M.

Hi,

On Wed, Apr 16, 2008 at 10:07 AM, Jeff M. [email protected]
wrote:

I’d like to add functionality that checks
if the server exists. Is there a way to do this? Perhaps with win32ole?

I suppose it depends - `exists’ according to what definition?

Arlen

if the server exists. Is there a way to do this? Perhaps with win32ole?

  • Jeff M.

perhaps this is what your looking for?

ip = 127.0.0.1
storage = []

storage << system(“ping #{ip}”)

storage
#=> [true]


ip = 1.0.0.1
storage.clear

storage << system(“ping #{ip}”)

storage
#=> [false]

  • Mac

thanks! I will test this tomorrow since I’m off work today, but this
looks like what I’ve been looking for :slight_smile:

Could I use the server name instead of the IP in the same way?

Woops, you have to “” ip.

ip = “127.0.0.1”

Otherwise you get a syntax error :slight_smile:

Regards,

  • Mac

Could I use the server name instead of the IP in the same way?

Yea no problem there, however I will issue the warning of this:

Wouldn’t be hard for someone to slip a del -qf . in that system call
and wipe out your drive, at least thats what I think it is on windows.
Just be careful who you let around it :slight_smile:

If its just you using it, shouldn’t have any problem at all.

Regards,

  • Mac

thanks! It worked flawlessly!!

On Thu, Apr 17, 2008 at 3:36 PM, Jeff M. [email protected]
wrote:

thanks! It worked flawlessly!!

What worked flawlessly? I hope it was Gordon’s suggestion, but even
that is not flawless to determine that it’s an exchange server. You
need to --for lack of a better term-- “exchange” with it to ensure
that it is, in fact, an exchange server, and a true ping hardly serves
the purpose.

Todd

On Wed, Apr 16, 2008 at 3:18 PM, Michael L.
[email protected] wrote:

Regards,

  • Mac

Another way is to check if the server is listening on a port an
Exchange server would listen on, like IMAP4(143), or SMTP(25)

require ‘ping’
=> true

Ping.pingecho(‘exchange_server’,5,143)
=> true

Hope that helps,

Gordon

For my purposes, it worked flawlessly. I used this:

  ip = params[:ex_name]
  storage = []
  storage << system("ping #{ip}")
  if storage == [true]
     blah blah
  end

I don’t need to determine right away if it is an exchange server or not.
I have also tried Gordon’s response, which works. I basically just need
to check whether it’s there or not.

Thanks,

  • Jeff

[mailto:[email protected]] On Behalf Of Jeff M.

ip = params[:ex_name]

storage = []

storage << system(“ping #{ip}”)

if storage == [true]

blah blah

end

I don’t need to determine right away if it is an exchange

server or not. I have also tried Gordon’s response, which

works. I basically just need to check whether it’s there or not.

just in case you’ll need it, you can telnet to it

eg, here is one simple way (among other ways),

require ‘net/telnet’
#=> true

x = Net::Telnet::new(“Host” => “MYMAIL”, “Port” => 25,
“telnetmode”=>false)
#=> #TCPSocket:0x28b0374

puts x.gets
220 MYMAIL.mydomain.com Microsoft ESMTP MAIL Service, Version:
6.0.3790.3
959 ready at Sat, 19 Apr 2008 11:04:57 +0800
#=> nil

that is an exchange 2003 iianm

kind regards -botp

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs