help with rsh

I am trying to run a Perl script using rsh. I need to be able to capture the return code value, so the calling script can handle failures properly.

I cannot modify the Perl script I need to run because we use it for all of our servers.

Does anyone have a suggestion?

try:

rsh <client> '<script>;echo $?'

Note the single quotes as they cause the string to be sent in entirety to the client; without them, the 'echo' statement will end up running on the local server.