Re: return code wierdness
Posted in 1994
> > > Are any of you Informix Gurus using the remote shell sometimes? > > I want to run a command on a remote machine, and get the return code > back into my 4GL program. > > As Jack Parker didn't write: > > From 4gl: > RUN command RETURNING retcode > # command is "rsh cpu2 xyz.4ge.sh" Problem 0: rsh is restricted shell, you probably mean remsh. > > on cpu2, xyz.4ge.sh contains: > #!/bin/sh > xyz.4ge > echo $? > return_code Problem 1: xyz.4ge.sh will return a 0. Because as a shell it will probably run fine. What you want to do is: #!/bin/sh xyz.4ge return $? Or just invoke xyz.4ge directly. Be sure to retcode=retcode/256. Problem 2: (from the man page) RETURN VALUE If remsh fails to set up the secondary socket connection, it returns 2. If it fails in some other way, it returns 1. If it fully succeeds in setting up a connection with remshd, it returns 0 once the remote command has completed. Note that the return value of remsh bears no relation to the return value of the remote command. The problem with remsh is that it is a local command and is running just fine. Its return_code is going to be zero anyway. What you need is to get that return code shipped back to your local system as in: remsh nodename "command" > localfile; cat localfile where nodename:command is something like: ls non-existant file echo $? This executes 'command' on the remote system and echoes the return code into a local file called, appropriately, 'localfile'. The rest of the line just cats that file. j. ____________________________________________________________________________ -- Jack Parker | Hewlett Packard, BSMC Boise, Idaho, USA| He who talks most, talks least. jparker@hpbs3645.boi.hp.com | _____________________________________________________________________________ Any opinions expressed herein are my own and not those of my employers. _____________________________________________________________________________