Checking several file shares with one single test

If you have information, script, utility, or idea that can be useful for HostMonitor community, you welcome to share information in this forum.
Post Reply
AlexL
Posts: 62
Joined: Tue Jul 18, 2006 9:56 am
Location: Switzerland

Checking several file shares with one single test

Post by AlexL »

In this shell script test I am using the IF EXIST command to check a file share:

Code: Select all

@ECHO OFF
SET server=%1
SET count_missing=0 & SET count_total=0

:check_share
SHIFT
IF "%1"=="" GOTO end
SET /A  count_total+=1
IF NOT EXIST \\%server%\%1 (
  SET /A  count_missing+=1
  SET missing=%missing% %1
)
goto check_share
:end

IF NOT "%missing%"=="" (
   ECHO ScriptRes:Bad:Missing: %count_missing%: %missing%
) ELSE (
   ECHO ScriptRes:Ok:%count_total% of %count_total% OK
)

SET server=
SET count_missing=
SET count_total=
SET missing=
with these Params:

<SERVER> <share> <share> ....

where <share> is the is the share name, for example home$. The share being checked is \\SERVER\home$.

On Bad status, the Reply lists the shares which are not available.

Alex
Post Reply