Activate and deactivate function within a ksh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Activate and deactivate function within a ksh script
# 1  
Old 03-28-2012
Lightbulb 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....

Code:
#/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...

# 2  
Old 03-28-2012
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:-

Code:
blinkon=`tput blink`
blinkoff=`tput rmso`

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


I hope that this helps,

Robin
Liverpool/Blackburn,
UK
# 3  
Old 03-29-2012
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?


Quote:
Originally Posted by rbatte1
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:-

Code:
blinkon=`tput blink`
blinkoff=`tput rmso`

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

I hope that this helps,

Robin
Liverpool/Blackburn,
UK
---------- 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...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass and read an array in ksh shell script function.?

I'm able to read & print an array in varaible called "filelist" I need to pass this array variable to a function called verify() and then read and loop through the passed array inside the function. Unfortunately it does not print the entire array from inside the funstion's loop. #/bin/ksh... (5 Replies)
Discussion started by: mohtashims
5 Replies

2. Shell Programming and Scripting

In ksh script what is this BEGIN and END in this function?

Can Someone please explain why BEGIN and END statement is used inside function? How does that help in scripting? function fileformatting { CleanupMask="xXxX" sed 's/^.//' < ${AllFile} > ${AllFile}.tmp echo $(wc -l ${AllFile}.tmp) `awk -v CleanupMask=${CleanupMask} ' BEGIN... (2 Replies)
Discussion started by: later_troy
2 Replies

3. Shell Programming and Scripting

Ksh script function, how to "EXIT 2" without killing the current process?

Hi, Using AIX 5.3 and Ksh. />ls -al /usr/bin/ksh -r-xr-xr-x 5 bin bin 237420 Apr 10 2007 /usr/bin/ksh /> I recently started working for a new employer. I have written UNIX K-Shell scripts for many years and have never had this particular issue before. Its perplexing me. I have... (2 Replies)
Discussion started by: troym72
2 Replies

4. Shell Programming and Scripting

Activate all Linux services script

Now i'm up to making a script from which you could activate all Linux services without being an expert. It's gonna be a powerful tool, I'll look forward to make it able to change the port which the service is assigned to. But I need some help, post some script to activate services and I'll fusion... (8 Replies)
Discussion started by: Dax01
8 Replies

5. Shell Programming and Scripting

Can you ref/link/import a function from external ksh script?

Hey guys, I'm not the best AIX scripter about but I can flounder my way thru them to create what I need. Anyhow, I have various scripts that perform various actions and processes. I was tasked to come up with a single form of logging that all the scripts could implement so that the output... (2 Replies)
Discussion started by: isawme
2 Replies

6. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies

7. UNIX for Advanced & Expert Users

activate and deactivate

hi all by using gethostbyname, i can know whether the net is available or not. it is working fine when i activate or deactivate in neat. the problem is when i remove cable(netcable) it is not working proparly, i would like to know it. am using fedora5, AMD can u please help me . thank... (3 Replies)
Discussion started by: munna_dude
3 Replies

8. Shell Programming and Scripting

need script for activate and deactivated databases in server

Hi all, i am using below command to find the running datases, bases this command i need a (shell/korn)script for which databases are running and which databases are not running in one file. i need out put below format. Kindly help to me. its very critical issue for me. i dont have script... (3 Replies)
Discussion started by: krishna176
3 Replies

9. Shell Programming and Scripting

ksh: can you use getopts in a function?

I wrote a script that uses getopts and it works fine. However, I would like to put the function in that script in a startup file (.kshrc or .profile). I took the "main" portion of the script and made it a function in the startup script. I source the startup script but it doesn't seem to parse... (4 Replies)
Discussion started by: lyonsd
4 Replies

10. UNIX for Dummies Questions & Answers

deactivate users

Hi all, we are running an hp-ux sd32 server with hp-ux 11.11 and i have to modify 130 users on the system, so that they are inactive. We have not installed the security package, so i cannot use usermod -e 2/24/04 qsc0017. Is there anyone who knows one command which i can use to change the user... (2 Replies)
Discussion started by: ortsvorsteher
2 Replies
Login or Register to Ask a Question