tc shell script: undefined variable
Can someone tell me what I am doing wrong with set flag1.. i am getting an error of flag1: Undefined variable.
if($notLoaded1 > 0) then
开发者_如何学Python echo "Rows not loaded due to data errors in first load: $notLoaded1"
set flag1=1
endif
if($notLoaded2 > 0) then
echo "Rows not loaded due to data errors in second load: $notLoaded2"
set flag2=1
endif
if($notLoaded3 > 0) then
echo "Rows not loaded due to data errors in third load: $notLoaded3"
set flag3=1
endif
echo $flag1
echo $flag2
echo $flag3
is there a way to check all three of them in one if statement or rather than using 3 if statements
if ($flag1 > 0) then
exit 1
endif
if ($flag2 > 0) then
exit 1
endif
if ($flag3 > 0) then
exit 1
endif
Thank you
What do you need 3 flag variables for?
set error=0
if ($notLoaded1 > 0) then
echo "Rows not loaded due to data errors in first load: $notLoaded1"
set error=1
endif
if ($notLoaded2 > 0) then
echo "Rows not loaded due to data errors in second load: $notLoaded2"
set error=1
endif
if ($notLoaded3 > 0) then
echo "Rows not loaded due to data errors in third load: $notLoaded3"
set error=1
endif
if ($error) then
exit 1
endif
flag1
only gets set if $notLoaded1
is greater than 0. So if it's zero, you don't get a $flag1.
I'd suggest initializing those three variables with defaults beforehand:
set flag1=0
if (...) the
set flag1=1
echo 'Rows not loaded...'
endif
That'll guarantee that flag1 always exists.
精彩评论