Path: utzoo!news-server.csri.toronto.edu!rutgers!sun-barr!newstop!male!anywhere.EBay.Sun.COM!me From: me@anywhere.EBay.Sun.COM (Wayne Thompson - IR Workstation Support SE) Newsgroups: comp.lang.perl Subject: perl and rsh Message-ID: <5514@male.EBay.Sun.COM> Date: 11 Mar 91 14:34:17 GMT Sender: news@male.EBay.Sun.COM Lines: 46 Has anyone come up with a reliable way to use rsh (remote shell) from perl? Rsh can hang causing perl to wait for completion. What I've done to work around the problem is to attach a handler to $SIG{'ALRM'} which kills any rsh commands attached to the current terminal: $SIG{'ALRM'} = 'RemoteConnectionHandler'; foreach $client (sort (keys (%cantalkto))) { $cmd = "rsh $client cat $PASSWD"; ($pid = open (REMOTE_CONNECTION, "$cmd 2>&1 |")) || die "\n$MYNAME: $cmd: $!\n"; alarm ($timeout); while () { alarm (0); ... alarm ($timeout); } alarm (0); close (REMOTE_CONNECTION); } sub RemoteConnectionHandler { &grepkill (&SIGKILL, $cmd); close (REMOTE_CONNECTION); } sub grepkill { local ($sig, $pat, $pid) = @_; $pat =~ s/(\W)/\\$1/g; open (PS, "ps $$|"), ; open (PS, "ps -t".(split (' ', ))[1]."|"), ; kill ($sig, grep (/$pat/, )); close (PS); } I'm looking for a better way to do this. As this depends on /.rhosts for access, using chat and the ftp port is not a viable alternative. I also notice that rcmd is not availble as a syscall. Any ideas? Wayne