RETURN BASH values always 0..no matter what...

bostonmacosx

Newcomer
Joined
Dec 19, 2014
Messages
1
Reaction score
0
Points
0
So I have:

Code:
dsmadmc  -se=$i -id=XXXX -pa=XXX -errorlogname=/tmp/tsmerror.log -outfile=/METRICS/BACKUP/FILES/$filename.txt -tabdelimited   'select domain_name, schedule_name, node_name,substr(char(scheduled_start), 1, 16) as "SCHEDULED_START",substr(char(actual_start), 1, 16) as "ACTUAL_START",status, result, reason from events where (scheduled_start between '"'"$yesterdaytime"'"' and '"'"$nowtime"'"') and LENGTH(domain_name) IS NOT NULL  order by scheduled_start,status,result,reason'


if [ "$?" = "0" ]; then
    echo 'success';
else
echo 'failure';
  echo $? | mail -s "DSMADMC DAILY TRANSFER QUERY ERROR: $i" [email protected]
fi

Even if I change the password so that it fails on login I still get a "0" for the return value.
So I can't send out a failure email.

How can I get around this?

Thanks
 
For one reason or another, TSM does not give a proper exit code when used in a script. It seems to 'live' in its own environment.

To get around it, I capture the output and grep for key words for 'success' or 'failure'. Not desirable in most cases but works.
 
Back
Top