Hi for all, on unix when i use the ping command and a machine returns with
time out the SO returns to me with the code 1, telling me that i hadn´t no
answer. On Windows if a computer returns with time out the windows returns
to me a return code 0. How do i do to got the correct return code of
Windows. I need a return code other 0 when a computer times out.
Try the FREE Mount/\Command called .Alive
It is based on Ping.exe and works CONSISTENTLY
across NT/2K/XP/K3.
*******
A frequent SysAdmin need is to check the accessibility of a remote
system by using the native Ping utility. A new M^^C called .Alive
provides a CONSISTENT self-documenting method to check one machine,
a list of machines or an entire range of IP addresses.
The variable which contains the input is called, of course, %Alive%.
The scripting code is stored in variable %.Alive%.
Since the input is expanded at runtime, you can set the input value
and run the command within the same line of code! Delayed Variable
Expansion is not necessary, allowing full compatibility across
NT/2K/XP/K3. The self-documenting code looks like this:
FOR /L %%A IN (1,1,254) DO @(
(SET "Alive=10.7.7.%%A")
(%.Alive%)
)
..Alive takes the internal Ping command up on Mount Knowledge!
The code above will check the entire address range from
10.7.7.1 through 10.7.7.254, reporting on each address in turn.
But it get even better than that!
Success is reported to STDOUT, failure is reported to STDERR.
So, to see only the addresses that are active, suppress STDERR
using the %.Kity% {Keep-It-To-Yourself] command.
FOR /L %%A IN (1,1,254) DO @(
(SET "Alive=10.7.7.%%A")
(%.Alive% %.Kity%)
)
To see only the machines that are inaccessible,
suppress STDOUT using the %.Quiet% command.
FOR /L %%A IN (1,1,254) DO @(
(SET "Alive=10.7.7.%%A")
(%.Alive% %.Quiet%)
)
Additional examples are on the pre-release ".Alive Page" at
(
http://TheSystemGuard.com/MtCmds/CrystalClear/Alive.htm).
There is also a link there to download the pre-release code
and test it on your machine.
To look up the syntax of any other "Mounted Commands"
used in the examples, see the Master Catalog at
(
http://TheSystemGuard.com/MasterCatalog.asp).
-tsg
/-----------------+---------------+----------------------\
| COMPATIBILITY | CLARITY | SPEED |
| Write code ONCE | Make it clear | THEN...Make it fast! |
\-----------------+---------------+----------------------/
400+ command-line resources using ONLY native NT commands!
(
http://TheSystemGuard.com/default.asp#MasterCommandList)