---------- Post updated at 02:16 PM ---------- Previous update was at 11:36 AM ----------
Here is both versions going back to prompt with just ONE (ENTER) keystroke :
The one which displays a bar of sharps :
Code:
#!/bin/bash -
# Arrêt par création de fichier
# Version:1.0.2d
# Au choix: croix tournante ou barre d'avancement;
# Inverser les commentaires pour sélectionner la boucle du
# mode choisi. Faire Entrée pour arrêter le processus.
#
clear;echo
#+++++++++++++++++++++++++++++++++++++++ partie à insérer en tête de script (supprimer la boucle superflue)
PID=$$
# initialisation
barre-init()
{
STOP=$(mktemp -u --suffix=.stop-barre --tmpdir=$HOME/tmp)
trap "rm -f $STOP; exit" EXIT HUP INT QUIT ABRT TERM
}
# Affiche une barre avec des dièses ou une croix tournante
function barre()
{
tput civis;tput bold;tput sc
# Affiche une barre avec des dièses (5 '#'/s)
#--------------------------
COLS=$(tput cols);x=0 # Mémorise la largeur du terminal
while : ; do
sleep 0.2;tput rc;tput hpa $x;tput el;echo -n "#"
let "x += 1"
if [ $x = $COLS ]; then tput rc;tput dl1;x=0;fi
if [ -f $STOP ]; then break;fi
if [ $((x % 5)) = 0 ]; then
if [ "`ps h $PID`" = "" ]; then break;fi
fi
done
#--------------------------
# Affiche la croix tournante (1 rotation/s)
#---------------------------------------
# while : ; do
# sleep 0.125;tput rc;tput dl1;echo -n " |"
# sleep 0.125;tput rc;tput dl1;echo -n " /"
# sleep 0.125;tput rc;tput dl1;echo -n " -"
# sleep 0.125;tput rc;tput dl1;echo -n " \\"
# sleep 0.125;tput rc;tput dl1;echo -n " |"
# sleep 0.125;tput rc;tput dl1;echo -n " /"
# sleep 0.125;tput rc;tput dl1;echo -n " -"
# sleep 0.125;tput rc;tput dl1;echo -n " \\"
# if [ -f $STOP ]; then break;fi
# if [ "`ps h $PID`" = "" ]; then break;fi
# done
#---------------------------------------
tput rc;tput dl1;tput sgr0;tput cnorm;tput ed
}
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fin de la fonction pour un script
# Lancement de la fonction: barre
barre-init # à placer dans un script au début de l'opération: téléchargement, recherche etc... ***
barre & # idem ***
# Instructions d'arrêt de ce script
read
> $STOP # instruction d'arrêt de la barre d'attente à placer à la fin de l'opération ***
tput rc;tput dl1
sleep 1 # faire une pause pour revenir en avant plan avant d'envoyer une commande d'avant plan.
exit 0
and the one which displays a rotating cross :
Code:
#!/bin/bash -
# Arrêt par création de fichier
# Version:1.0.2d
# Au choix: croix tournante ou barre d'avancement;
# Inverser les commentaires pour sélectionner la boucle du
# mode choisi. Faire Entrée pour arrêter le processus.
#
clear;echo
#+++++++++++++++++++++++++++++++++++++++ partie à insérer en tête de script (supprimer la boucle superflue)
PID=$$
# initialisation
barre-init()
{
STOP=$(mktemp -u --suffix=.stop-barre --tmpdir=$HOME/tmp)
trap "rm -f $STOP; exit" EXIT HUP INT QUIT ABRT TERM
}
# Affiche une barre avec des dièses ou une croix tournante
function barre()
{
tput civis;tput bold;tput sc
# Affiche une barre avec des dièses (5 '#'/s)
#--------------------------
# COLS=$(tput cols);x=0 # Mémorise la largeur du terminal
# while : ; do
# sleep 0.2;tput rc;tput hpa $x;tput el;echo -n "#"
# let "x += 1"
# if [ $x = $COLS ]; then tput rc;tput dl1;x=0;fi
# if [ -f $STOP ]; then break;fi
# if [ $((x % 5)) = 0 ]; then
# if [ "`ps h $PID`" = "" ]; then break;fi
# fi
# done
#--------------------------
# Affiche la croix tournante (1 rotation/s)
#---------------------------------------
while : ; do
sleep 0.125;tput rc;tput dl1;echo -n " |"
sleep 0.125;tput rc;tput dl1;echo -n " /"
sleep 0.125;tput rc;tput dl1;echo -n " -"
sleep 0.125;tput rc;tput dl1;echo -n " \\"
sleep 0.125;tput rc;tput dl1;echo -n " |"
sleep 0.125;tput rc;tput dl1;echo -n " /"
sleep 0.125;tput rc;tput dl1;echo -n " -"
sleep 0.125;tput rc;tput dl1;echo -n " \\"
if [ -f $STOP ]; then break;fi
if [ "`ps h $PID`" = "" ]; then break;fi
done
#---------------------------------------
tput rc;tput dl1;tput sgr0;tput cnorm;tput ed
}
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fin de la fonction pour un script
# Lancement de la fonction: barre
barre-init # à placer dans un script au début de l'opération: téléchargement, recherche etc... ***
barre & # idem ***
# Instructions d'arrêt de ce script
read
> $STOP # instruction d'arrêt de la barre d'attente à placer à la fin de l'opération ***
tput rc;tput dl1
sleep 1 # faire une pause pour revenir en avant plan avant d'envoyer une commande d'avant plan.
exit 0
consider the given prg.
main() {
.....
function1(); /* to write into a file or log */
printf(" ");
.....
}
when the control reaches function1(), it should get executed in the
background.At the same time main's printf(" ") statement should also get executed.i.e... (5 Replies)
Dear all,
I'm writing a KornShell script that calls inside it a function in background mode
#!/bin/ksh
function myfunction
{ . . .}
myfunction |&
. . .
How can I capture the PID of the function myfunction that runs in background?
Thanks in advance
:) (2 Replies)
I'm writing a PHP script which will take a given media file and convert it into a flash (flv) file. In addition to this, once the flv file has been generated I create two thumbnails (of different sizes) from the newly generated flv file.
In order to do this I'm calling ffmpeg from the command... (4 Replies)
hello all,
In my script i have written some messages which should come in screen while some background process is going on..
Like for example:
if i want to add 2 numbers a and b ...when the addition is going on in the background i should get "ADDING TWO NUMBERS>>PLEASE WAIT " message on... (3 Replies)
Guys
I'm working to make in AIX script and I have some commands need to be excited by that script
Like the below commands ...
startsrc -s sshd
I want that executing to be in the background of the system I do not like to see the out put of that (3 Replies)
Hi All,
I have an issue where in when i execute a script in the background using '&', it exits with stopped(SIGTTOU) signal.
There are two servers, where the Compute server is HP-Unix and Data server is Linux.
I tried using the "stty - tostop" command to disable the SIGTTOU for background... (1 Reply)
Here is some back ground on the script. The script is to poll an arbitrary number of DB's. To do this I am creating a function that takes the file_path to the DB and the min poll interval as arguments. The function will be called for each DB and then ran in the background. The function I was... (6 Replies)
Greetings, i've been working with a user-friendly menu on ksh to allow users execute scripts located on a remote server, so they wont have to login and manually launch those scripts every single time.
This is a HP-UX box and currently on a /usr/bin/ksh shell.
I've setup ssh keys on both... (1 Reply)
Hi,
I am having script which contains many functions. Need to print each function name at the starting of the function. Like below,
functionname()
{
echo "functionname"
commands....
}
I've tried like below,
func=`grep "()" scriptname | cut -d "(" -f1`
for i in $func
do
nawk -v... (4 Replies)