bsharath
asked on
Ping one from from within each machine whose name is in the list.
Hi,
Ping one from from within each machine whose name is in the list.
I have a list of machine names in a txt file
I want to go into the machine and ping my exchange server for example to check if the ping works fine from within each client
Regards
Raja
Ping one from from within each machine whose name is in the list.
I have a list of machine names in a txt file
I want to go into the machine and ping my exchange server for example to check if the ping works fine from within each client
Regards
Raja
Something like
@ECHO OFF
SET LogFile=%~n0.log
SET PClist=%~n0.csv
SET Server=exchangeserver
FOR /F "delims=" %%A in (%PClist%) DO PSEXEC \\%%A PING -n 1 exchangeserver && (ECHO OK %%A>>%LogFile%&ECHO OK %%A) ELSE (ECHO ER %%A>>%LogFile%&ECHO ER %%A)
PAUSE
Forgot to mention, that it's a batch file.
ASKER
eager which script is this?
renege i get this
ELSE was unexpected at this time.
renege i get this
ELSE was unexpected at this time.
Maybe I tried to much to do a one liner out of this.
Try this one
Try this one
@ECHO OFF
SET LogFile=%~n0.log
SET PClist=%~n0.csv
SET Server=exchangeserver
FOR /F "delims=" %%A in (%PClist%) DO (
PSEXEC \\%%A PING -n 1 %Server% && (
ECHO OK %%A>>%LogFile%
ECHO OK %%A
) ELSE (
ECHO ER %%A>>%LogFile%
ECHO ER %%A
)
)
PAUSE
How are you doing so far?
ASKER
I get this
C:\>"Ping one from other.bat"
ELSE was unexpected at this time.
C:\>"Ping one from other.bat"
ELSE was unexpected at this time.
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET LogFile=%~n0.log
SET PClist=%~n0.csv
SET Server=exchangeserver
FOR /F "delims=" %%A in (%PClist%) DO (
PSEXEC \\%%A PING -n 1 %Server% >NUL
IF !errorlevel! == 0 (
ECHO OK %%A>>%LogFile%
ECHO OK %%A
) ELSE (
ECHO ER %%A>>%LogFile%
ECHO ER %%A
)
)
PAUSE
ASKER
Where should i store the machinenames?
Whats the file name?
Whats the file name?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
while read MACHINE ; do
ping -c 1 $MACHINE
done < machine_list.txt
You probably want to add checks to see if this works.