> Is there an equivalient to TMOUT in the bourne shell ?
and has the same meaning as in ksh.
HTH,
Roberto Nibali, ratz
--
> Is there an equivalient to TMOUT in the bourne shell ?
HTH,
Roberto Nibali, ratz
--
The below is a [bourne shell] function that puts the time in the
prompt; it uses a background process that send SIGUSR1 every so
often to the shell having a trap handler to execute this function.
I though to rewrite the function to be more pertainent to your
problem, but as I have no access to bourne shell on my FreeBSD ISP,
at least I know that _this_ works, and is applicable to the problem
with some code "massaging". Keep in mind, though, that as a user-level
process the sophisticated user can defeat this "TMOUT" emulation (as
with ksh's TMOUT, if one has not read the documentation!)
=Brian
#! /bin/echo error: only source
#*TAG:50041 2:Oct 17 1998:0644:mkprompt_sh:
# Copyright: (c) 1998
# Date: 1998/10/02
# Description: put the time in PS1 -- bourne shell version
# Name: mkprompt_sh
# Requires: autoload, mapsig, require
# Usage: mkprompt_sh
# Version: 1.01
#02
mkprompt_sh() # [-]
{ # uses global variables _prevsec and _ps1
# define custom prompt here: $1=hours $2=minutes $3=seconds
_force= _sleep= : ${_ps1:='[$1:$2]$ '}
#_force= _sleep= : ${_ps1:=' [7m$1:$2$ [m '}
test X$1 = X- && _force=ON shift
set -- `date '+%H %M %S'`
if test X$_force = XON -o 0${_prevsec:-60} -gt 0$3
then eval PS1="\"$_ps1\"" _sleep=`expr 50 - $3`
test 0$_sleep -le 0 && _sleep=5
else _sleep=49 # default period
case $3 in
0?) eval PS1="\"$_ps1\"" ;;
1?) _sleep=39 ;;
2?) _sleep=29 ;;
3?) _sleep=19 ;;
4?) _sleep=7 ;;
5[0-5]) _sleep=3 ;;
5?) _sleep=2 ;;
esac
fi
eval ${DIAG:+'echo [ mkprompt_sh: _prevsec=$3 sleeptime=$_sleep ] >&2'}
(sleep $_sleep; kill -30 $$) </dev/null & # signal 17 = SIGUSRig
_prevsec=$3
#03Quote:}
#04Quote:}
#05 EMBEDDED MANPAGE FOR "src2man"
: '
#++
NAME
mkprompt_sh - a mkprompt(3S) for sh(1)
SYNOPSIS
DESCRIPTION
OPTIONS
RETURN CODE
EXAMPLE
ENVIRONMENT
FILES
SEE ALSO
mkprompt(3S)
CAVEATS
An "alias" for the builtin "cd" is defined that uses the undocumented
builtin "chdir" that is implemented only in sh(1), not ksh(1).
BUGS
It is hardcoded within sh(1) that if the shell detects it is in an
interactive environment, the PID of an invoked background process
will be printed to /dev/tty, and thus cannot be redirected.
#--
'
1. How do I use ksh TMOUT on 5.2
hopefully easy question: how do I access the TMOUT variable to zap an
idle user. Ideally I'd like to trap it in a user's login shell. MKS
doc indicates that TMOUT's sends a SIGALRM, but ksh does not seem
recognize such a signal on the unix 5.2 system I am running ksh on. I
manually set TMOUT to '1', and got a 'shell timeout in 60 seconds' with
every tap of the return key!
Thanks in advance...
+-------------------------------------------------------+
| Timothy Reed - American Chemical Society |
| UUCP: ..uunet!wash08!txr98 |
| USMAIL: 1155 16th NW^MRoom 412^MWashington, DC 20036 |
| VOICE: 202 872-6018 |
+-------------------------------------------------------+
2. RS-232 Port Access in Unix Environment
3. TMOUT in ksh
4. AIX on a G3?
5. TMOUT in KSH
6. Strange sound problem under X
7. ksh TMOUT environment variable
8. But how do you install those programs ???
9. TMOUT in ksh
10. root's shell, /sbin/sh, /bin/sh and /usr/ksh
11. ksh toto.sh/toto.sh and sleep
13. Execute a sh script under perl and sh: sh script; perl script?