Да, вот так как то получилось:
Код:
#!/bin/sh
SBRFDIR=/usr/local/auth/sbrf
case $1 in
7)
sudo $SBRFDIR/t/ukm_runsbrf_in.sh $@
sudo $SBRFDIR/g/ukm_runsbrf_in.sh $@
cp -f -p $SBRFDIR/t/e $SBRFDIR/e
cat $SBRFDIR/t/p $SBRFDIR/g/p > $SBRFDIR/p
;;
[1-3])
let SumT=0
let SumG=0
let SumAll=$2*1
let SumAllD=0
let CodeOp=$1*1
while read line ; do
IFS=";"
set -- $line
dept=$1
sm=$2
sm=${sm/./}
if [[ "$dept" -eq "2" ]]; then
let SumT=sm
let SummAllD=SummAllD+SumT
else
let SumG=sm
let SummAllD=SummAllD+SumG
fi
done < /tmp/s
if (( SumAll = SummAllD )); then
Succ=0
echo "2, !!!" > $SBRFDIR/t/e
echo "2, !!!" > $SBRFDIR/g/e
if [[ "$SumT" -ne "0" ]]; then
sudo $SBRFDIR/t/ukm_runsbrf_in.sh $CodeOp $SumT 0
read line < $SBRFDIR/t/e
IFS=","
set -- $line
ErCode=$1
if [[ "$ErCode" -ne "0" ]]; then
Succ=1
fi
cp -f -p $SBRFDIR/t/e $SBRFDIR/e
fi
if [[ "$SumG" -ne "0" && "$Succ" -eq "0" ]]; then
sudo $SBRFDIR/g/ukm_runsbrf_in.sh $CodeOp $SumG 0
read line < $SBRFDIR/g/e
IFS=","
set -- $line
ErCode=$1
if [[ "$ErCode" -ne "0" ]]; then
Succ=1
# Возврат?
if [[ "$SumT" -ne "0" && "$CodeOp" -eq "1" ]]; then
let NS=0
while read linefile ; do
let NS=NS+1
if [[ "$NS" -eq "4" ]]; then
line=$linefile
fi
done < $SBRFDIR/t/e
sudo $SBRFDIR/t/ukm_runsbrf_in.sh 13 $SumT $line
fi
fi
cp -f -p $SBRFDIR/g/e $SBRFDIR/e
fi
if [[ "$Succ" -eq "0" ]]; then
if [[ "$SumT" -ne "0" ]]; then
cp -f -p $SBRFDIR/t/p $SBRFDIR/p
if [[ "$SumG" -ne "0" ]]; then
cat $SBRFDIR/t/p $SBRFDIR/g/p > $SBRFDIR/p
fi
else
cp -f -p $SBRFDIR/g/p $SBRFDIR/p
fi
fi
else
echo "1,Сумма по отделам не совпадает с итогом." > $SBRFDIR/e
fi
;;
esac
exit 0