Activate and deactivate function within a ksh script

Hi,

I have written a function which will blink a text "Scanning...". Now in the main script when I am doing the scan in the server I want to call this function so that user will see a blinking text on the screen and at the same time script will proceed will the scan function. Once scan is finished - I want to deactivate blink function. Please advise how this can be done....

#/bin/ksh
function blinkScanning()
{

i=0
while i=9999
do
echo "Scanning...\c"
sleep 1
echo "\b\b\b\b\b\b\b\b\b\b\b\b\c"
echo "           \c"
sleep 1
echo "\b\b\b\b\b\b\b\b\b\b\b\b\c"
i=$(($i+1))
done
}

#Main script

# capture user inputs
echo "Enter data1"
read DATA1
echo "Enter data2"
read DATA2

# call function blinkScanning something like below
blinkScanning &

#proceed futher while text is blinking 
do
scan operations...
scan operations...
scan operations...
done

#stop blink text somehow
echo "Done"

#print results...

After blinkScanning you can get the PID you just spawned, then after you scan is complete, kill that process. Value is $!

Of course, I'm left wondering why you don't just display the message as a blinking message? Try:-

blinkon=`tput blink`
blinkoff=`tput rmso`

echo "${blinkon}Scanning .......${blinkoff}\r\c"
scan operations
echo "                 "

I hope that this helps,

Robin
Liverpool/Blackburn,
UK

Yeah - I tried using tput before but somehow its now working in AIX - I am writing a script for AIX+SUN+LINUX so to make sure it works in all three OSes I have written this blink function using simple echo cmd.

Also when I call the function linke "blinkScanning &" it displays the job no. and pid on screen - how this can be avoided?

---------- Post updated 03-29-12 at 11:06 AM ---------- Previous update was 03-28-12 at 06:34 PM ----------

Any further help on this is much appreciated...