Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I am using korn script to launch an ADV+ program (a legacy language) based on certain conditions. The full script is given below.
=============================================
#!/usr/bin/kshscnUser=$1
scnProg=$2
while true
do
begin:
clear
tempFile="/out/uow.$$"
uid=`id -un`
tFile1="/out/"${uid}"_1.$$"
tFile2="/out/"${uid}"_2.$$"
errFile="/out/"${uid}"_$$.err"
echo $scnUser > $tFile1
tr 'a-z' 'A-Z' < $tFile1 > $tFile2
read scnUpperUser < $tFile2
rm -f $errFile 2>/dev/null
rm -f $tFile1 2>/dev/null
rm -f $tFile2 2>/dev/null
rm -f $tempFile 2>/dev/null
echo ; echo
print -n "[scnloc-$scnUpperUser]"
echo
print -n "Scan WO >"
read uow
uow_length=${#uow}
echo $uow > $tempFile
if [[ $uow = "EXIT" ]] || [[ $uow = "exit" ]]
then
exit 0
fi
if [ $uow_length -ne 13 ] ; then
echo
echo " Invalid UOW."
echo " ===================="
echo " 'Y' to Clear Error"
echo " ?"
read _getY
if [ $_getY = "Y" ] ; then
goto begin
fi
fi
echo "Program is $scnProg"
run $scnProg $scnUser $errFile < $tempFile 2>/dev/null
if [ -e $errFile ] ; then
cat $errFile
echo
echo " ==================="
echo " 'Y' to Clear Error"
echo " ?"
read _getY
if [ $_getY = "Y" ] ; then
continue
fi
fi
echo "Loging Off [$scnProg]"=============================================
You could see that there is a goto begin in the script where the uow_length is not equal to 13. This goto is not working. Basically I want go back to the begin of the do loop and it should wait for the response for the statement "read uow". I tried continue and it doesn't seem to work either. Can some one help me how to go the begining of the loop when the uow_length is not equal to 13? I can code the remaining part of the script in the else part, but I don't wanna do that.
Thanks,
Balaji.

I don't see where the problem is, but it looks like the if statement is failing. This small test script works on my Solaris 9 system:
#!/bin/ksh_getY="Y"
if [ $_getY = "Y" ] ; then
echo "getY is Y"
firead uow
uow_length=${#uow}
echo $uow_lengthif [ $uow_length -ne 13 ]; then
echo "Invalid UOW"
fiDoes it work on yours? if it doesn't then your problem is somewhere else.
Have you tried something like this:
if [[ ${uow_length} -ne 13 ]] ; then
echo "Invalid UOW"
fi

Hi,
My script is working fine. I figured out that I need to use "continue" statement to go back to the next iteration.
Thanks for your response.
Thanks,
Balaji.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |