Operating System - HP-UX
1755088 Members
3952 Online
108829 Solutions
New Discussion юеВ

Re: Catch return code into remote command execution

 
SOLVED
Go to solution
Jose Mosquera
Honored Contributor

Catch return code into remote command execution

I guys,

I have the following reliable way to validate into a script if a system is trusted or not:
SYS_TRUSTED=`/usr/lbin/getprdef -r 2>1 > /dev/null;echo $?`
If return code is 0 the system is trusted.
So, I'm trying to catch this return code against a remote machine using the similar syntax:
REMOTE_SYS_TRUSTED=`remsh hostname -l root -n "/usr/lbin/getprdef -r;echo $?"`
The problem here is that always catch zero status, I guess that remsh return code is catched instead of "getprdef" return code.
Some hint about?

Please omit recomendation about "/tcb" folder validation or "*" in password field of /etc/passwd file.

Rgds.
3 REPLIES 3
Ivan Krastev
Honored Contributor
Solution

Re: Catch return code into remote command execution

See this old thread how to capture exit code on rsh - http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=944722

regards,
ivan
Jose Mosquera
Honored Contributor

Re: Catch return code into remote command execution

Thanks Ivan, the old thread have a lot useful info, analyzing that information could see that the trick is in using simple quotation marks instead of double quotation marks, being in the following way:
#REMOTE_SYS_TRUSTED=`remsh remotehost -l root -n '/usr/lbin/getprdef -r 2>1 > /dev/null;echo $?'`

Then $REMOTE_SYS_TRUSTED have the correct return code of the command "getprdef".

Thanks!
Jose Mosquera
Honored Contributor

Re: Catch return code into remote command execution

Above explained, best regards.