rsh status using ersh

rsh status using ersh

Post by csupin.. » Tue, 03 Aug 1999 04:00:00



Donn,

The program I attached was just a copy of the
ersh program you had originally suggested.  The
only modification I made was the path to rsh
that you mentioned.  As you say, I just use
"ersh" instead of "rsh" when I try to execute
the remote shell.  For some reason, it never
gets to the "NR > 1" or the "NR = 1" portion of
the awk statement so prev, prev1 and prev2 are
never setup.  Because of this, it falls through
the if statements and always returns an exit
status of 1.  Thanks for all your help.

Chuck Supinski




> | I recently tried to use the "ersh" script

created by Maarten Litmaath to
Quote:> | retrieve the status of the remote command

rather than the rsh command.
Quote:> | However, it always returned a status of 1 no

matter what I tried.  I am
Quote:> | a relative neophite when it comes to complex

UNIX commands and awk so
Quote:> | could someone explain what the it is doing

(I'm OK until the "exec3>&1"
Quote:> | line and I understand the "rsh" command until

it starts echoing and
Quote:> | redirecting things) or what I'm doing wrong. I
have attached the
> | program.

> I am sorry to say, the program you attached

didn't make it.  It was
Quote:> pretty badly garbled in transmission.

> Here's one tip - it looked to me like you may

have tried to integrate
Quote:> your script into the ersh script, and that

wouldn't be a good idea.
Quote:> It's rather complicated even if you understand
all the details and
> what it's trying to do, but you don't have to

look inside, just use
Quote:> use it IN PLACE of rsh.

> Well, you do have to look inside if you need to

replace /usr/ucb/rsh
Quote:> with /usr/bin/remsh or something like that, but

just do what you need
Quote:> to make it work.  Try it with a simple command,
like
> "./ersh remote-host echo hi"

> exec 3>&1 opens a new unit 3 on the old unit 1

output stream.  Then
Quote:> in the rsh|awk pipe, where unit 1 is now the

pipe, he restores the old
Quote:> unit 1 with >&3, after adding unit 2 to the pipe

with 2>&1.  In other
Quote:> words, he's juggling file descriptors to make

unit 2 go through the
Quote:> pipe instead of unit 1.

> A lot of the complexity is there because the

remote shell might be csh
Quote:> or tcsh.  We'll never be finished paying the

price for that bad idea.
Quote:

>    Donn Cave, University Computing Services,

University of Washington

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

1. rsh exit status using ersh

I recently tried to use the "ersh" script created by Maarten Litmaath to
retrieve the status of the remote command rather than the rsh command.
However, it always returned a status of 1 no matter what I tried.  I am
a relative neophite when it comes to complex UNIX commands and awk so
could someone explain what the it is doing (I'm OK until the "exec3>&1"
line and I understand the "rsh" command until it starts echoing and
redirecting things) or what I'm doing wrong. I have attached the
program.

Thanks

ersh expects to find commands in their original Berkeley names and
places, so you will have to edit it a bit to accommodate your platform.

Donn Cave, University Computing Services, University of Washington

-----------------------------
#!/bin/sh

# This rsh front-end returns the exit status of the remote command. # It
works OK with sh/csh-compatible shells on the remote (!) side. # If
there is no remote command present,
/usr/ucb/rlogin is invoked. # Usage: see rsh(1).

# unset hostname lflag nflag user

case "$1" in
      -l)
;;
      *)
hostname=$1
shift
esac

case "$1" in
      -l)
lflag=-l
user=$2
shift 2
esac

case "$1" in
      -n)
nflag=-n
shift
esac

case "$hostname" in
      '')
hostname=$1
shift
esac

case $# in
      0)
exec /usr/ucb/rlogin $lflag ${user+"$user"} "$hostname" esac

AWK='
NR > 1 {
   print prev;
   prev = $0;
   prev1 = $1;
   prev2 = $2;
NR == 1 {
   prev = $0;
   prev1 = $1;
   prev2 = $2;
END {
   if (prev1 ~ /[0-9]*[0-9]0/)
   exit(prev1 / 10);
   if (prev1 == "0")
   exit(prev2);
   print prev;
   exit(1);
'

exec 3>&1

/usr/ucb/rsh "$hostname" $lflag ${user+"$user"} $nflag \ "(${*-:}); sh
-c '"'echo "$0 $1" >&2'\'' $?0 "$status"' \ 2>&1 >&3 3>&- | awk "$AWK"

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

2. xdm LOGIN help

3. ersh - rsh frontend hack returning exit status of remote cmd

4. Setting environment for rsh (Korn Shell)

5. rsh - getting the status of an rsh'd command

6. Newbie Q:installing sendmail 8.11 on MKLinux

7. exit status using rsh

8. USB DAQ device driver help

9. Move "used FPU status" into new non-atomic thread_info->status field.

10. Problem using ufsdump to remote tape called using rsh

11. How to get the exit status of a remote command executed via rsh

12. getting rsh status