Solved

display seconds remain with sleep mode unix

Posted on 2007-11-18
6
297 Views
Last Modified: 2011-10-03
hi i just have a quick question how do i display the seconds a sleep coomand stll has before it ontinues?
e.g
sleep 10

echo "you have x seconds before you can continue"
0
Comment
Question by:DSwiftie
6 Comments
 
LVL 6

Expert Comment

by:Talmash
ID: 20307730
do you want it counting down?
0
 

Author Comment

by:DSwiftie
ID: 20308143
yep def
0
 
LVL 48

Accepted Solution

by:
Tintin earned 100 total points
ID: 20308567
#!/bin/sh
secs=10

while [ $secs -gt 0 ]
do
     echo "You have $secs seconds before continuing"
     secs=`expr $secs - 1`
    sleep 1
done
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:Talmash
ID: 20312042
little change to tintin's:

file = sleep_countdown:
#!/bin/sh
secs=$1

while [ $secs -gt 0 ]
do
     echo "You have $secs seconds before continuing"
     secs=`expr $secs - 1`
    sleep 1
done

chmod 755 sleep_countdown

sleep_countdown 30

you can change the resolution by setting it VIA $2 (set step = $2 ...)

tal
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 20312395
Hi,

try this script (call it myscript)

count=$1
while test $count -gt 0
do
echo "time left $count \c"
sleep 1
count=`expr $count - 1`
echo "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\c"
done
echo "\n"

you may use it as

myscript 30
0
 

Author Comment

by:DSwiftie
ID: 20316128
tin tin's one works thankyou all very much for ur help
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now