Operating System - HP-UX
1752777 Members
6118 Online
108789 Solutions
New Discussion юеВ

looking for a "watch" command for hpux...

 
Manuel Contreras
Regular Advisor

looking for a "watch" command for hpux...

I was wondering if anyone knew of where I could find the watch command for hpux.

checked the usual sources, and no luck.

Currently I have the following shell equivalent for the watch command:

$ cat watch
#!/bin/sh

while [ 1 ] ; do
clear
echo "Command: $*"
date
echo ""
( $* )
sleep 2
done

$

does anyone know of a gnu-watch (or equivalent) for hpux?

thanks and hh,
manny

3 REPLIES 3
Olivier Masse
Honored Contributor

Re: looking for a "watch" command for hpux...

Someone showed me watch on Linux last year and I just had to have it myself, so I tried to compile it on 11.31 and threw the towel... didn't want to spend an afternoon tweaking it. I wrote a shell script which is strikingly similar to yours and it does the job.

Olivier
T. M. Louah
Esteemed Contributor

Re: looking for a "watch" command for hpux...

A simple approach would be to append a copy of everything printed to the user's screen to a file; Execute "script" command at user's terminal after he logs in (add it to his profile) :

"script -a /tmp/watch.user"

At your terminal execute "tail -f /tmp/watch.user"; you will get a real-time view of what user's cmds & outputs.

Other than that you can move to VNC or HP's SharedX ...or others.
T#
Little learning is dangerous!
Viktor Balogh
Honored Contributor

Re: looking for a "watch" command for hpux...

yeah, I always do these things with "while true; do...sleep". However, do not have an alias for that.

@Louah: no, this 'watch' isn't used for watching users activity. This is for running a command every x seconds and watch it's output. A linux-friend of mine has showed me it, and he wondered that we don't have such a 'tool' on HP-UX.

btw: from 'man watch':

"watch - execute a program periodically, showing output fullscreen"
****
Unix operates with beer.