|
From: | Julio C. Neves |
Subject: | Re: [shell-script] Contagem de tempo em background |
Date: | Fri, 23 Dec 2016 10:12:40 -0200 |
Shell básico e Programação em Shell Julio Neves
Bacula Heitor Medrado
Zabbix Adail Host
Falae pessoal,
Bem, estou criando um script para contagem de tempo fazendo uso do tput. A ideia é que o script mostrasse a mensagem de tempo no final da tela (rodando em background), mas que pudesse liberar o shell na parte de cima para que o usuário pudesse fazer outras coisas e quando a contagem encerrar, finalizaria com outra mensagem de fim. Sei que é possível dividir a tela com o tput, mas não sei como fazer. Há alguma forma de liberar o shell para o usuário, enquanto a mensagem é mostrada no final da tela? Ou seja, limitaríamos uma pequena parte da tela para a mostragem das mensagens, enquanto a parte de cima do shell ficaria liberada para o usuário fazer outras coisas. Segue abaixo o script:
#!/bin/sh
LIN="`tput lines`"
COL=0
TEMPO=5
flag="0"
while [ "$flag" -eq "0" ]
do
tput ed
tput cup $LIN 0
echo "TEMPO RESTANTE: \c "
tput cup $LIN 22; echo "$TEMPO\c"
TEMPO=$(($TEMPO-1))
if [ $TEMPO -lt 0 ]
then
sleep 1
tput ed
tput cup $LIN 0
echo "O TEMPO ACABOU\c"
tput ed
flag="1"
fi
sleep 1
done &Abraço a todos,
Junior.
[Prev in Thread] Current Thread [Next in Thread]
- Contagem de tempo em background, jrsreis, 2016/12/22
- Re: Contagem de tempo em background, itamarnet, 2016/12/22
- Re: Contagem de tempo em background, jrsreis, 2016/12/22
- Re: [shell-script] Contagem de tempo em background, Julio C. Neves <=
- Re: [shell-script] Contagem de tempo em background, jrsreis, 2016/12/26
- Re: [shell-script] Contagem de tempo em background, Julio C. Neves, 2016/12/26
- Prev by Date: Re: Contagem de tempo em background
- Next by Date: Um animação em ascii
- Previous by thread: Re: Contagem de tempo em background
- Next by thread: Re: [shell-script] Contagem de tempo em background
- Index(es):