home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.rexx
- Path: sparky!uunet!mcsun!sunic!aun.uninett.no!ugle.unit.no!ugle!anders
- From: anders@lise11.lise.unit.no (Anders Christensen)
- Subject: Re: Capturing System Command Output (was: SH Backquote)
- In-Reply-To: jpr@hp10.lri.fr's message of 19 Aug 92 13:54:45 GMT
- Message-ID: <ANDERS.92Aug19215104@lise11.lise.unit.no>
- Sender: news@ugle.unit.no (NetNews Administrator)
- Organization: /home/flipper/anders/.organization
- References: <19920818081215SEB1525@MVS.draper.com> <1992Aug19.155445@hp10.lri.fr>
- Date: 19 Aug 92 21:51:04
- Lines: 67
-
- In article <1992Aug19.155445@hp10.lri.fr> jpr@hp10.lri.fr (Jean-Pierre Riviere) writes:
-
- > Well, I am not a specialist but whatthe hell is the "RESULT" var done for ?
-
- The special variable RESULT is set at the return from a subroutine
- called by a CALL clause, when the called routine returned a result, in
- order to catch a value that would otherwise be lost.
-
- To call a program and get the RESULT variable set on return, and still
- be within TRL, do the following:
-
- call 'ls' "-l ~"
- dir = result
-
- Note the difference between calling an external function, and issuing
- a command, that is two conceptually very different methods.
-
- Unfortunately, it is not clearly specified in TRL _what_ to interpret
- as the 'result' from an external function if it is not a rexx
- function. Is it the output (the characters written to standard
- output); or is it the return value (the expression given to statements
- like exit and return?)
-
- > Would not be the better way be
- >
- > "ls -l ~"
- > dir = result
-
- Perhaps, but if the program has more complex output, like the
- 'directory/full' under vms, you're stuck with one mega RESULT string,
- and have to do some moby parsing to get the various fields. Putting
- the result from a command into a single variable _only_ works (in a
- practical sense) if the output is either small or well structured.
-
- As a concequence, there most a another method (either instead of or in
- addition to the result-method), that handles complexly structured
- output from commands. The solution _might_ be to use compound
- variables in stead of simple variables (i.e. result.1, result.2 ....
- etc, instead of just result). But I don't think that the only Correct
- Answer either.
-
- > (This is the only available way to do it with arexx btw)
- > It's common rexx anf follows Cowlishaw's rules. (as far as I
- > understood it...)
-
- IMHO this is not TRL, and IMNSHO arexx is not TRL.
-
- > So why are you trying to implement hassles with
- >
- > dir = "ls -l ~"
- >
- > and all its derivative ?
-
- The statement that you think of is probably something like
-
- dir = "ls"( "-l ~" )
-
- Which is calling the program 'ls' with the parameter(s) '-l ~' and
- assigning the 'outdata' (whether it be the return code or standard
- output) to the variable 'dir'. That _is_ within TRL, although it does
- not require it.
-
- > Cannot the result way be good enough for us ?
-
- As a solution, yes. As the only solution, no.
-
- -anders
-