In my script I am trying to input data from user and I want the promt to appear again if the input data is not the one expected.
I tried something like this:
echo " \n\n\t Enter the dump filename:\c";read dump
pst=${dump##*.}
until (test $pst = dmp)
do
echo " \n\n\t File extension not supported.!!!"
echo " \n\n\t Enter the dump filename(eg:abc.dmp):\c"
read dump
done
but this not become false in any case and the prompt is apprearing again and again even if the condition is met(ie,if the user inputs .dmp file)
Where did I go wrong?
One more issue the "" worked only first time..
That is when I gave .dmp after accessing the script for the first time it goes through and comes to next step.
but when I gave .dmp again after an error it again throwed error
That is , If I commit a mistake once I dont get a chance to rectify the same.
Can any one please explain why is this so? Is this a property of "until"?
First thing is that you have a logic problem.
you're saying "until" $pst,
the you read & set dump, and then don't reset what pst is??
How would that ever work??
#!/usr/bin/ksh
print " \n\n\t Enter the dump filename:\c"; read dump
pst=${dump##*.}
until [ $pst = dmp ]
do
print " \n\n\t File extension not supported.!!!"
print " \n\n\t Enter the dump filename(eg:abc.dmp):\c"
read dump
pst=${dump##*.}
done