HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Error handling in shellscript

 
mxbala
Occasional Visitor

Error handling in shellscript

I have written shell script to find out pairsuspends in our environment.But when i run the script iam getting an error for the Pair which are not active.Below are the error am getting
pairvolchk -g up1012 -I11
pairvolchk : execution error.
pairvolchk: [EX_ENQCTG] Unmatched CTGID within the group
Refer to the command log(/HORCM/log11/horcc_fauna.log) for details

How could i avoid those errors while running script.Below are the ouput while running the script


./checkpair.sh 11
pairvolchk : execution error.
pairvolchk: [EX_ENLDEV] No such LDEV within the RAID
Refer to the command log(/HORCM/log11/horcc_fauna.log) for details.
pairvolchk : execution error.
pairvolchk: [EX_ENLDEV] No such LDEV within the RAID
Refer to the command log(/HORCM/log11/horcc_fauna.log) for details.
pairvolchk : execution error.
pairvolchk: [EX_ENLDEV] No such LDEV within the RAID
Refer to the command log(/HORCM/log11/horcc_fauna.log) for details.

pairvolchk : execution error.
pairvolchk: [EX_ENLDEV] No such LDEV within the RAID
Refer to the command log(/HORCM/log11/horcc_fauna.log) for details.
pairvolchk : execution error.
pairvolchk: [EX_ENQCTG] Unmatched CTGID within the group
Refer to the command log(/HORCM/log11/horcc_fauna.log) for details.
pairvolchk : execution error.
pairvolchk: [EX_ENQCTG] Unmatched CTGID within the group
Refer to the command log(/HORCM/log11/horcc_fauna.log) for details.

2 REPLIES
Suraj K Sankari
Honored Contributor

Re: Error handling in shellscript

Hi,
You can redirect your error
./my_script > file <-- Redirect standard output
./my_script 2> file <-- Redirect error output
./my_script &> file <-- Redirect all output


see the examples
Ex: ./my_script &> capture.txt

for more details see the below link
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_07

Suraj

mxbala
Occasional Visitor

Re: Error handling in shellscript

Suraj

Thanks for the response.i have redirecting some of the outputs to the file.Below are the details
cat /etc/horcm$1.conf | grep -i flo |grep -v ^# |awk '{print $1}'> ${LogDir}/horcm$1.out
for i in `cat $LogDir/horcm$1.out`
do
echo $i `pairvolchk -g $i -I$1` >> /tmp/offshore/out/$1.out
done