Ребят помогите сделать циклы if then else правильно чтобы проверял expect
expect -c "
set timeout 120
spawn scp -r /home/administrator/crontab/ $username@$H:/home/administrator
expect password ;
send \"$password\n\" ;
expect \"scp>\""
then echo "OK" ; else echo "NO"; fi
if
expect -c "
set timeout 1
spawn ssh $username@$H;
expect password ;
send \"$password\n\" ;
expect *> ;
send \"sudo mkdir /home/user/.cron\n\" ;
expect password ;
send \"$password\n\" ;
expect *> ;
send \"sudo cp -f -rp /home/administrator/crontab/crontab/del.sh /home/user/.cron\n\" ;
expect *> ;
send \"sudo crontab -u user /home/administrator/crontab/crontab/reg\n\" ;
expect *> ;
send \"sudo rm -rf /home/administrator/crontab\n\" ;
expect \"ssh>\""