[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Check if remote server exists

Jeff Miller

4/16/2008 12:08:00 AM

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
--
Posted via http://www.ruby-....

9 Answers

Arlen Cuss

4/16/2008 12:58:00 PM

0

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

Hi,

On Wed, Apr 16, 2008 at 10:07 AM, Jeff Miller <loadeddesigns@gmail.com>
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

Michael Linfield

4/16/2008 5:46:00 PM

0

> 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
--
Posted via http://www.ruby-....

Michael Linfield

4/16/2008 5:57:00 PM

0

Woops, you have to "" ip.

ip = "127.0.0.1"

Otherwise you get a syntax error :)

Regards,

- Mac
--
Posted via http://www.ruby-....

Jeff Miller

4/16/2008 8:08:00 PM

0

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?
--
Posted via http://www.ruby-....

Michael Linfield

4/16/2008 8:19:00 PM

0

> 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

--
Posted via http://www.ruby-....

Gordon Thiesfeld

4/16/2008 8:57:00 PM

0

On Wed, Apr 16, 2008 at 3:18 PM, Michael Linfield
<globyy3000@hotmail.com> wrote:
> > 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

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

Jeff Miller

4/17/2008 8:36:00 PM

0

thanks! It worked flawlessly!!
--
Posted via http://www.ruby-....

Todd Benson

4/18/2008 10:48:00 PM

0

On Thu, Apr 17, 2008 at 3:36 PM, Jeff Miller <loadeddesigns@gmail.com> 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

Jeff Miller

4/18/2008 11:26:00 PM

0

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
--
Posted via http://www.ruby-....