PC Review


Reply
Thread Tools Rate Thread

Command to check remote system

 
 
=?Utf-8?B?R2Fsb3A=?=
Guest
Posts: n/a
 
      11th Mar 2005
I need to execute few file transfer commands from a local system only after
the remote destination is reachable. Example:

Check whether I can reach 192.168.32.x
Then execute file transfer commands.

I tried ping the remote site and capture the %errorlevel%. But this is "0"
for success or failure.
 
Reply With Quote
 
 
 
 
Torgeir Bakken \(MVP\)
Guest
Posts: n/a
 
      11th Mar 2005
Galop wrote:

> I need to execute few file transfer commands from a local system
> only after the remote destination is reachable. Example:
>
> Check whether I can reach 192.168.32.x
> Then execute file transfer commands.
>
> I tried ping the remote site and capture the %errorlevel%. But this
> is "0" for success or failure.

Hi

This is a "bug" in Win2k's ping.exe that is fixed in WinXP.

The best solution I have found to detect if a computer is online or not
is to search for the text "TTL=" in the output from ping.exe. I have
found it to work all situations/languages I have come up with.

So this should work fine for both WinXP and Win2k:

'--------------------8<----------------------
set host=128.33.12.144
set connected=N
for /f "Tokens=*" %%c in ('ping -n 1 %host% ^| FIND "TTL="') do (
set connected=Y
)
if "%connected%" EQU "Y" echo %host% is online
'--------------------8<----------------------



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scr...r/default.mspx
 
Reply With Quote
 
nospam.please@ualberta.ca
Guest
Posts: n/a
 
      11th Mar 2005
"=?Utf-8?B?R2Fsb3A=?=" <(E-Mail Removed)> wrote in
news:90C2EAF4-1BED-40C9-8720-(E-Mail Removed):

> I need to execute few file transfer commands from a local system only
> after the remote destination is reachable. Example:
>
> Check whether I can reach 192.168.32.x
> Then execute file transfer commands.
>
> I tried ping the remote site and capture the %errorlevel%. But this is
> "0" for success or failure.


Instead of PING, you could try the freeware ALIVE (which does return an
errorlevel) available at:

http://wettberg.home.texas.net/freeware.htm

But, just PINGing may tell you that the computer is on, but not whether it
actually is ready to accept file transfers. If a computer boots up, it may
answer a PING before the server and logon services are fully running. You
may have to insert a delay if this is a possiblity.

You could also try something like:

IF EXIST \\192.168.32.x\sharename (insert file transfer command here)
 
Reply With Quote
 
=?Utf-8?B?R2Fsb3A=?=
Guest
Posts: n/a
 
      11th Mar 2005
Thankyou very much to both of you. Actually, I need to perform file transfer
using batch mode ftp with batch script. I agree that, ping may go though but
ftp may not go though if the ftp service is not started at other end. Is
there a better way to manipulate this issue?

"(E-Mail Removed)" wrote:

> "=?Utf-8?B?R2Fsb3A=?=" <(E-Mail Removed)> wrote in
> news:90C2EAF4-1BED-40C9-8720-(E-Mail Removed):
>
> > I need to execute few file transfer commands from a local system only
> > after the remote destination is reachable. Example:
> >
> > Check whether I can reach 192.168.32.x
> > Then execute file transfer commands.
> >
> > I tried ping the remote site and capture the %errorlevel%. But this is
> > "0" for success or failure.

>
> Instead of PING, you could try the freeware ALIVE (which does return an
> errorlevel) available at:
>
> http://wettberg.home.texas.net/freeware.htm
>
> But, just PINGing may tell you that the computer is on, but not whether it
> actually is ready to accept file transfers. If a computer boots up, it may
> answer a PING before the server and logon services are fully running. You
> may have to insert a delay if this is a possiblity.
>
> You could also try something like:
>
> IF EXIST \\192.168.32.x\sharename (insert file transfer command here)
>

 
Reply With Quote
 
Mike Jones
Guest
Posts: n/a
 
      12th Mar 2005
Torgeir Bakken (MVP) wrote:
> Galop wrote:
>
>> I need to execute few file transfer commands from a local system
>> only after the remote destination is reachable. Example:
>>
>> Check whether I can reach 192.168.32.x
>> Then execute file transfer commands.
>>
>> I tried ping the remote site and capture the %errorlevel%. But this
>> is "0" for success or failure.

> Hi
>
> This is a "bug" in Win2k's ping.exe that is fixed in WinXP.
>
> The best solution I have found to detect if a computer is online or
> not is to search for the text "TTL=" in the output from ping.exe. I
> have found it to work all situations/languages I have come up with.
>
> So this should work fine for both WinXP and Win2k:
>
> '--------------------8<----------------------
> set host=128.33.12.144
> set connected=N
> for /f "Tokens=*" %%c in ('ping -n 1 %host% ^| FIND "TTL="') do (
> set connected=Y
> )
> if "%connected%" EQU "Y" echo %host% is online
> '--------------------8<----------------------


The following adaptation is backwardly compatible


@echo off
if #%1==# goto usage
if not #%2==# goto usage
set ol=off
ping -n 1 %1 |FIND "TTL=">nul
if not errorlevel 1 set ol=on
if "%connected%" == "Y" echo %1 is %ol%line
goto exit
:Usage
echo Usage is %0 hostname or IP
:exit


 
Reply With Quote
 
Al Dunbar [MS-MVP]
Guest
Posts: n/a
 
      13th Mar 2005

"Torgeir Bakken (MVP)" <Torgeir.Bakken-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Galop wrote:
>
> > I need to execute few file transfer commands from a local system
> > only after the remote destination is reachable. Example:
> >
> > Check whether I can reach 192.168.32.x
> > Then execute file transfer commands.
> >
> > I tried ping the remote site and capture the %errorlevel%. But this
> > is "0" for success or failure.

> Hi
>
> This is a "bug" in Win2k's ping.exe that is fixed in WinXP.


Interesting. I just pinged (pung?) a non-existent IP address, got four
"Request timed out" responses, and the errorlevel was set to 1. Pinging
localhost returned, as expected, a code of 0. But what do these errorlevel
codes tell you? I would guess that 0 means that some response was received
and that 1 means none. Unless this assumption can be verified, I would
consider looking for "TTL=" as being the more reliable method.

/Al

> The best solution I have found to detect if a computer is online or not
> is to search for the text "TTL=" in the output from ping.exe. I have
> found it to work all situations/languages I have come up with.
>
> So this should work fine for both WinXP and Win2k:
>
> '--------------------8<----------------------
> set host=128.33.12.144
> set connected=N
> for /f "Tokens=*" %%c in ('ping -n 1 %host% ^| FIND "TTL="') do (
> set connected=Y
> )
> if "%connected%" EQU "Y" echo %host% is online
> '--------------------8<----------------------
>
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scr...r/default.mspx



 
Reply With Quote
 
Torgeir Bakken \(MVP\)
Guest
Posts: n/a
 
      13th Mar 2005
Al Dunbar [MS-MVP] wrote:

> "Torgeir Bakken (MVP)" <Torgeir.Bakken-(E-Mail Removed)> wrote:
>> Galop wrote:
>>
>>>I need to execute few file transfer commands from a local system
>>>only after the remote destination is reachable. Example:
>>>
>>>Check whether I can reach 192.168.32.x
>>>Then execute file transfer commands.
>>>
>>>I tried ping the remote site and capture the %errorlevel%. But this
>>>is "0" for success or failure.

>>
>>
>>This is a "bug" in Win2k's ping.exe that is fixed in WinXP.

>
>
> Interesting. I just pinged (pung?) a non-existent IP address, got four
> "Request timed out" responses, and the errorlevel was set to 1. Pinging
> localhost returned, as expected, a code of 0. But what do these errorlevel
> codes tell you? I would guess that 0 means that some response was received
> and that 1 means none. Unless this assumption can be verified, I would
> consider looking for "TTL=" as being the more reliable method.

Hi

Yes, pinging a non-existing computer name/ip address will give error
level 1 on Win2k, but if you ping a computer that is registered in your
DNS, but the computer is offline, Win2k will return error level 0,
while WinXP will return error level 1 (that is more correct, as
ping.exe was not able to connect to the computer).


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scr...r/default.mspx
 
Reply With Quote
 
Michael Bednarek
Guest
Posts: n/a
 
      14th Mar 2005
On Fri, 11 Mar 2005 14:01:01 -0800, "Galop"
<(E-Mail Removed)> wrote in
microsoft.public.win2000.cmdprompt.admin:

>Thankyou very much to both of you. Actually, I need to perform file transfer
>using batch mode ftp with batch script. I agree that, ping may go though but
>ftp may not go though if the ftp service is not started at other end. Is
>there a better way to manipulate this issue?


This is how I do that kind of thing using 4NT, a commercial CLI:
IFTP "ftp://192.168.32.x"
IFF %_? EQ 0 THEN
COPY sourcefile "ftp:"
IFTP /C
ELSE
ECHO IFTP failed.
ENDIFF

IFTP is a built-in command in 4NT; it provides for transparent file
operations to FTP hosts; it's documentetd at
<http://jpsoft.com/help/iftp.htm>.

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run command on remote system =?Utf-8?B?QW1iaWNhIEphaW4=?= Microsoft C# .NET 2 3rd Jun 2006 05:31 AM
GPO to check box in System Properties to allow remote connection =?Utf-8?B?Um9iZXJ0TkM=?= Microsoft Windows 2000 Group Policy 2 12th Jan 2005 02:47 PM
Re: command line to check who is logged in on remote machine Walter Schulz Microsoft Windows 2000 Networking 2 11th Sep 2003 03:35 PM
Re: command line to check who is logged in on remote machine Jamie Microsoft Windows 2000 Networking 0 10th Sep 2003 08:51 PM
command line to check who is logged in on remote machine Microsoft Windows 2000 Networking 0 10th Sep 2003 06:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:50 PM.