?
Solved

display seconds remain with sleep mode unix

Posted on 2007-11-18
6
Medium Priority
?
327 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 400 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…
Suggested Courses

752 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