Check if remote server exists

J

Jeff Miller

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 Miller
 
A

Arlen Cuss

[Note: parts of this message were removed to make it a legal post.]

Hi,

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
 
M

Michael Linfield

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

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
 
M

Michael Linfield

Woops, you have to "" ip.

ip = "127.0.0.1"

Otherwise you get a syntax error :)

Regards,

- Mac
 
J

Jeff Miller

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

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

Michael Linfield

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 :)

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

Regards,

- Mac
 
G

Gordon Thiesfeld

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 :)

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

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)
=> true

Hope that helps,

Gordon
 
T

Todd Benson

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
 
J

Jeff Miller

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top