#!/bin/sh
# replace ping 127.0.0.1 with your command

TIMEOUT=5
ping 127.0.0.1 & CMDPID=!$

#start watchdog
(sleep ${TIMEOUT}; kill -9 ${CMDPID}) &
WATCHDOGPID=$!

#wait for command
wait ${CMDPID}
kill ${WATCHDOGPID} >/dev/null 2>&1

# more advanced script
# http://www.oase-shareware.org/shell/scripts/quickies/timeout


-- 
Mecho Puh
===========================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers)
http://www.linux-bulgaria.org/ Hosted by Internet Group Ltd. - Stara Zagora

Reply via email to