Real time clock in shell

Real time clock in shell

Post by tommyta » Tue, 20 Jun 2000 04:00:00



Dear all,

Recently I have a idea to display a real time clock at
the right bottom conner of my screen. (just like win95
little clock).

my idea is that, I can use `date` to form a while loop and
every time it display at the same line.

The Question is:
How can I control the output at the same location every
time and not affect other fount ground program?

I am using Linux and bash.

Thank You!

 
 
 

Real time clock in shell

Post by David Hasset » Tue, 20 Jun 2000 04:00:00



> Dear all,

> Recently I have a idea to display a real time clock at
> the right bottom conner of my screen. (just like win95
> little clock).

If you update this every second, you may find that the screen will
flicker too much for it to be in any way useful. I'd go for only
updating it every minute.

Quote:> my idea is that, I can use `date` to form a while loop and
> every time it display at the same line.

> The Question is:
> How can I control the output at the same location every
> time and not affect other fount ground program?

> I am using Linux and bash.

man tput

e.g. to place the cursor at position row 3 column 4, do:

tput cup 3 4

Cheers,

Dave :-)

 
 
 

Real time clock in shell

Post by Dale DePries » Tue, 20 Jun 2000 04:00:00


This works in ksh, you might try it in bash.
clock_p () {
PS1='${__[(H=SECONDS/3600%24)==(M=SECONDS/60%60)==(S=SECONDS%60)]-$H:$M:$S}>'
typeset -Z2 H M S; let SECONDS=`date '+(%H*60+%M)*60+%S'`

Quote:}

call this function and your prompt changes to a clock.

Dale


> Dear all,

> Recently I have a idea to display a real time clock at
> the right bottom conner of my screen. (just like win95
> little clock).

> my idea is that, I can use `date` to form a while loop and
> every time it display at the same line.

> The Question is:
> How can I control the output at the same location every
> time and not affect other fount ground program?

> I am using Linux and bash.

> Thank You!

--
For GPS data see: Joe -- http://joe.mehaffey.com
Peter -- http://www.vancouver-webpages.com/peter/
Karen -- http://www.gpsy.com/gpsinfo/
Dale -- http://users.cwnet.com/dalede
 
 
 

Real time clock in shell

Post by Matthew Land » Tue, 20 Jun 2000 04:00:00




> > Dear all,

> > Recently I have a idea to display a real time clock at
> > the right bottom conner of my screen. (just like win95
> > little clock).

> If you update this every second, you may find that the screen will
> flicker too much for it to be in any way useful. I'd go for only
> updating it every minute.

> > my idea is that, I can use `date` to form a while loop and
> > every time it display at the same line.

> > The Question is:
> > How can I control the output at the same location every
> > time and not affect other fount ground program?

> > I am using Linux and bash.

> man tput

> e.g. to place the cursor at position row 3 column 4, do:

> tput cup 3 4

> Cheers,

> Dave :-)

Printing ansi control chars also can work.  I know with these
ansi control chars, you can save and restore your cursor position.
this is nice to goto the postion, change the date, and return the
cursor to the origional position so the user doesn't get messed
up with the cursor jumping around.  Below is an example of the
single echo that could do the whole thing.  The \033 is the octal
representation of the ESC key.

echo "\033[s\033[24;50H$(date)\033[u\c"
     Save   move to  print  restore
     curs   row 24   date   curs
            col 50

Here is a simple script to show it working.

#!/bin/ksh
echo Hello
printf "Prompt Location: "
for i in 1 2 3 4
do
  echo "\033[s\033[20;50H$(date)\033[u\c"
  sleep 1
done

echo "STILL AT PROMPT"
# END KSH

 - Matt

 
 
 

Real time clock in shell

Post by Ken Pizzi » Wed, 21 Jun 2000 04:00:00



>> How can I control the output at the same location every
>> time and not affect other fount ground program?
>man tput

Also, man terminfo.

Quote:>e.g. to place the cursor at position row 3 column 4, do:

>tput cup 3 4

In order to return the cursor back to where it was before the
cup, you also need to know about the "sc" and "rc" capabilities.

More problemmatic, however, is how to ensure that the output of
this little function and the output of the "foreground process"
are not interleaved.  You can minimize the race condition by
having the clock code prepare a single string which it blats
out to the terminal (rather than doing its screen update piecemeal),
but even then you'll be subject to the occasional garbled display.

                --Ken Pizzini

 
 
 

Real time clock in shell

Post by bmar.. » Wed, 21 Jun 2000 04:00:00



   >Dear all,
   >Recently I have a idea to display a real time clock at
   >the right bottom conner of my screen. (just like win95
   >little clock).
   >my idea is that, I can use `date` to form a while loop and
   >every time it display at the same line.
   >The Question is:
   >How can I control the output at the same location every
   >time and not affect other fount ground program?
   >I am using Linux and bash.
   >Thank You!
If you are in X, you can use xclock.  In text mode I don't think there is
a practical way to do this while other programs are running.

Net-Tamer V 1.08X - Test Drive

 
 
 

1. Real-Time Clock

Hello,

We are planning to use a PC/104 embedded cpu  for
a project and we need to be able to sync our clock
with an external clock. I know that most boards come
with the MC146818 CMOS RTC, but from the data sheet,
it indicates that smallest unit of time that it will handle
is the second. Is there true? If so, how can keep time to the
millisecond level? Do I need to buy a separate time/counter circuit
with a crystal osciallator? I have a 1 Hz GPS pulse train
with very precise edges.

Thanks,
~Anthony

2. use seq_file for /proc/swaps

3. Real time clock delay problem

4. source for telnetd?

5. enhanced real time clock support; how to say 'y'

6. help qmail

7. UDB and Real Time Clock

8. Disk mounted, but files not seen

9. Real time clock (RTC) and UNIX

10. Kernel bug? Real Time Clock Freezes

11. Enhanced real time clock and Alpha UP2000 SMP

12. SCO Real Time Clock - Yeah Right!

13. Real Time Clock Drift