Solved

batch script to look for exceptions

Posted on 2008-10-10
4
86 Views
Last Modified: 2014-11-20
Hello,

Below is the command  i run to check my raid status :


C:\Program Files\PowerEdge Diagnostics\oldiags\bin>pediags 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:
@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
)

Open in new window

0
Comment
Question by:directi
  • 2
4 Comments
 
LVL 28

Expert Comment

by:Michael Pfister
ID: 22685759
@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
)
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
)
0
 
LVL 28

Accepted Solution

by:
Michael Pfister earned 125 total points
ID: 22685766
Sorry, wrong window
@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
)
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
)

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question