LINUX.ORG.RU
ФорумAdmin

return code


0

0

Hi!

Pomogite polu4it return code scripta "scr2":

myscript:
#!/bin/csh

rsh jupiter scr2
echo $status
--------------------------------
scr2:
#!/bin/csh
echo i am scr2
exit 15
--------------------------------

% myscript
i am scr2
0

Kak mne polu4it w myscript exit code ot scr2 ?
Tak kak $status = exit code ot rsh, a ne ot scr2

Spasibo za otwet!

anonymous

Боюсь что единственный метод это на удаленной машине вместо программы запускать скрипт которые запускает программу и печает код возврата на терминал. А скрипт в котором необходимо проверить код возврата должен обработать эту ситуацию. Давно было дело, но както сталкивался со скриптом ersh которые собсвенно делал все необходимое. Поищи может найдешь. Удачи.

anonymous
()
Ответ на: комментарий от anonymous

Кажется нашел реализацию выше сказанного. Новость 1993 года поэтому поищи может что более новое появилось...

Newsgroups: alt.sources
From: fnmpa@acad3.alaska.edu (ANDERSON MARK P)
Subject: ersh 3.1 - rsh frontend returning exit status of remote cmd
Message-ID: <30DEC199311464995@acad3.alaska.edu>
Sender: news@raven.alaska.edu (USENET News System)
Organization: University of Alaska - Fairbanks
Date: Thu, 30 Dec 1993 20:46:00 GMT

Archive-name: ersh 3.1
Submitted-by: fnmpa@acad3.alaska.edu

ersh is a front end to rsh which returns the exit status of the remote command,
or 99 if the connection is broken prematurely. If ersh is invoked without a
remote command, rlogin is invoked. Usage is the same as rsh(1).

ersh 3.0, posted to alt.sources by Maarten Litmaath on 4 June 91, did
not handle the -n flag correctly:

When the usage "ersh [ flags ] hostname [ command ]" was used, "-n" was not
recognized as a flag unless it was preceded by the "-l username" flag.

When the usage "ersh hostname [ flags ] [ command ]" was used, "-l" was not
recognized as a flag if the "-n" flag preceded it.

The following version of the ersh script corrects these problems:

--------------------cut here--------------------
#!/bin/sh
# ersh 3.1 93/12/30 Mark Anderson, slightly modified from
# ersh 3.0 91/06/04 Maarten Litmaath
# This rsh front-end returns the exit status of the remote command,
# or 99 if the connection is broken prematurely.
# It works OK with sh/csh-compatible shells on the remote (!) side.
# If there is no remote command present, rlogin is invoked, which
# need not return a meaningful exit status.
# Usage: see rsh(1).

RSH=/usr/ucb/rsh
RLOGIN=/usr/ucb/rlogin

hostname=
lflag=
nflag=
user=

# Check for usage like "ersh hostname [ flags ] [ command ]" and get the
# hostname if this is the case.
case $1 in
-l|-n)
;;
*)
hostname=${1?'hostname expected'}
shift
esac

# Check for "-l username" and "-n" flags and get them if they exist.
case $1 in
-l)
lflag=-l
shift
user=${1?'username expected after -l flag'}
shift
case $1 in
-n)
nflag=-n
shift
esac
;;
-n)
nflag=-n
shift
case $1 in
-l)
lflag=-l
shift
user=${1?'username expected after -l flag'}
shift
esac
;;
esac

# If hostname wasn't assigned earlier, usage must be like
# "ersh [ flags ] hostname [ command ]" and the hostname must be
# the next arg.
case $hostname in
'')
hostname=${1?'hostname expected'}
shift
esac

case $# in
0)
exec $RLOGIN $lflag $user "$hostname"
esac

id=ersh.$$.`date | awk '{ print $4; }'`
hangup=99

AWK='
prprev == 1 {
print prev0;
prprev = 0;
}
$1 == "'$id'" {
prev0 = $0;
prev2 = $2;
prev3 = $3;
prprev = 1;
next;
}
{
print;
}
END {
if (prprev == 0) {
exit('$hangup');
}
if (prev2 ~ /^[0-9]+0$/) {
exit(prev2 / 10);
}
if (prev2 ~ /^0$/ && prev3 ~ /^[0-9]+$/) {
exit(prev3);
}
exit('$hangup');
}
'

exec 3>&1

cmd="( ${*-:} ); exec sh -c 'echo $id "'"$0 $1" >&2'\'' $?0 "$status"'

$RSH "$hostname" $lflag $user $nflag "$cmd" 2>&1 >&3 3>&- |
awk "$AWK" >&2 3>&-

anonymous
()
Ответ на: комментарий от anonymous

Bolshoe spasibo za pomosh!

Ja sdelal tak kak wi posowetowali:

set rcode='rsh "jupiter scr2 | tail -1"'
a w scr 2 pered exit ja napisal:
echo 15

Eshe raz spasibo!

anonymous
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.