directi
asked on
batch script to look for exceptions
Hello,
Below is the command i run to check my raid status :
C:\Program Files\PowerEdge Diagnostics\oldiags\bin>pe diags raidctrl --show all|f
ind "Device Status"
Device Status : Device is working properly.
Device Status : Device is working properly.
Device Status : Device is working properly.
Device Status : Device is working properly.
Device Status : Device is working properly.
I would like to create a script which would throw an error if any of the lines beginning with "Device Status" have any output other than Device is working properly.Below is what i have so far:
Below is the command i run to check my raid status :
C:\Program Files\PowerEdge Diagnostics\oldiags\bin>pe
ind "Device Status"
Device Status : Device is working properly.
Device Status : Device is working properly.
Device Status : Device is working properly.
Device Status : Device is working properly.
Device Status : Device is working properly.
I would like to create a script which would throw an error if any of the lines beginning with "Device Status" have any output other than Device is working properly.Below is what i have so far:
@echo off
set status=0
cd C:\Program Files\PowerEdge Diagnostics\oldiags\bin
pediags -? > nul
if not %errorlevel%==0 (
echo Dell Poweredge Diagnostice is not installed or not in path
exit 2
)
cd C:\Program Files\PowerEdge Diagnostics\oldiags\bin
pediags raidctrl --show all |find "Device is working properly" >nul
if %errorlevel%==0 set status=0
if %status%==0 (
echo Raid is OK
exit 0
)
if %status%==1 (
echo Raid is DeGraded
exit 1
)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
set status=0
cd "C:\Program Files\PowerEdge Diagnostics\oldiags\bin"
pediags -? > nul
if not %errorlevel%==0 (
echo Dell Poweredge Diagnostice is not installed or not in path
exit 2
)
for /f "tokens=*" %%a in ('pediags raidctrl --show all ^| find "Device Status"') do If "%%a" NEQ "Device Status : Device is working properly." SET status=1
if %status%==0 (
echo Raid is OK
exit 0
)
if %status%==1 (
echo Raid is DeGraded
exit 1
)