Google Groups Home
Help | Sign in
Message from discussion rsh timeout technique needed
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Donn Cave  
View profile
 More options Apr 30 1999, 3:00 am
Newsgroups: comp.unix.admin, comp.unix.shell
From: d...@u.washington.edu (Donn Cave)
Date: 1999/04/30
Subject: Re: rsh timeout technique needed
Ted Estes <tes...@atl.com> writes:

| Problem:
| I need help finding a way to stop the attempt of a remote command after
| a given time. Sometimes an rsh command gets stuck on a system that isn't
| quite well and doesn't return. The sick system responds to ping but is
| just anti-social.

Might try something like this.

        Donn Cave, University Computing Services, University of Washington
        d...@u.washington.edu
-----------------------------
#!/bin/sh

timeout=$1
case $timeout in
[1-9]*) shift;;
*) timeout=10;;
esac

case $# in
0) echo 'Usage: timeoutrsh [timeout] cmd' >&2; exit;;
esac

rsh "$@" &
p=$!
(sleep $timeout; kill -1 $p) &
k=$!

wait $p
exit=$?
#  Normal exits are 0..127, signals are 128+signo
case $exit in
129)
        echo '(timed out)' >&2
        ;;
*)
        #  Kill the killer.
        kill $k
        ;;
esac
exit $exit


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google