#!/bin/sh
label:
echo sql poll
v=`sqlplus -s <<!
HR/HR
set pages 0 echo off feed off
select distinct status from
emp
where
id=5;
!
`
echo $v;
echo it comes here after false
if [ "$v" -eq 4 ]
then
echo if condition true
sqlplus -l scott/tiger <<EOF
select * from department;
EXIT
EOF
else
sleep 30;
goto label
fi
If the condition fails in the above script then it needs to sleep for 30 seconds then go to label and poll the database tabel. I read there is no goto in bourne shell so i tried to use other options like funtions but i could not finish this task. can someone help me to fix this. I tried like below . I am a absolute beginner in shell script so couldnot catch the concepts well.Thanks for your help in advance
#!/bin/sh
start(){
echo sql poll
v=`sqlplus -s <<!
HR/HR
set pages 0 echo off feed off
select distinct status from
emp
where
id=5;
!
`
echo $v;
}
rval=start
if [ "$rval" -eq 4 ]
then
echo if condition true
sqlplus -l scott/tiger <<EOF
select * from department;
EXIT
EOF
else
sleep 30;
start
fi