home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.rexx
- Path: sparky!uunet!gatech!news.byu.edu!eff!sol.ctr.columbia.edu!usc!wupost!think.com!news.bbn.com!noc.near.net!ns.draper.com!news.draper.com!MVS.draper.com!SEB1525
- From: SEB1525@MVS.draper.com (Steve Bacher)
- Subject: Re: Capturing System Command Output (was: SH Backquote)
- Message-ID: <19920819090033SEB1525@MVS.draper.com>
- Sender: MVS NNTP News Reader <NNMVS@MVS.draper.com>
- Nntp-Posting-Host: mvs.draper.com
- Organization: Draper Laboratory
- References: <ANDERS.92Aug18223235@lise8.lise.unit.no>
- Date: Wed, 19 Aug 1992 14:00:00 GMT
- Lines: 63
-
- In article <ANDERS.92Aug18223235@lise8.lise.unit.no>,
- anders@lise8.lise.unit.no (Anders Christensen) writes:
-
- >The three different _conceptual_ methods that I am aware of are
- [following very abbreviated]
- >
- > files = 'ls'(directory)
- > 'ls' directory ' >LIFO' /* or "|rxstack" */
- > 'ls | rxstack'
- > rcode = popen( "ls" directory,, "ls-output" )
-
- Er, our *four* different conceptual methods...?
-
- Just from the UI POV, how about a fifth:
-
- rcode = queue_to_stack("ls" directory)
-
- and
-
- rcode = dump_into_stem_vars("ls" directory, "STEMPREFIX.")
-
- (Choose your own function names - these are for self-evidentness.)
-
- Similar syntactically to popen(), but captures stdout and puts it
- on the data stack or in stem variables a la EXECIO.
-
- And what about stderr? Maybe an optional third argument could
- specify the destination for stderr. (Let's not get fancy and
- start specifying destinations for file descriptor numbers...)
-
- I don't like the ">LIFO" syntax because that conflicts with a
- valid file-redirection spec, using up potential file names in
- a magic-cookie sort of way. Also, this and the piping and popen
- solutions are too Unix-oriented in coding style; the programming
- interface to get at the data should be in the REXX culture, not
- the culture of the surrounding OS. This would also get around
- the "address something-other-than-the-native-shell" problem
- you alluded to with the 'address ftp; "ls | rxqueue"' difficulty.
-
- Implementation would probably involve the temporary redirection
- of stdout to somewhere where the output could be captured (e.g.
- a temporary file) and then unredirected at the end. The user's
- default shell (or shell specified by "address", maybe?) should be
- used to invoke the command. In cases where the command string is
- simple enough to allow for it, the command could be executed directly
- (e.g. via system), but this should be done only when the results would
- transparently be the same. (E.g. "cd" should fail to update the
- current directory as the REXX exec sees it, just as if it were shelled
- out, even if it wasn't.)
-
- >A better solution might be to label the _methods_ rather than the
- >_interpreters_, then it would be possible to check whether an
- >interpreter supports e.g. the popen-based method. Then the user don't
- >have to update his rexxscripts to support new interpreters, but new
- >interpreters will support the already existing methods.
-
- No, a better solution would be to have one method. Dispatching on
- whether a particular syntax is used is just as bad as, and possibly
- worse than, dispatching on a particular implememntation.
-
- --
- Steve Bacher (Batchman) Draper Laboratory
- Internet: seb@draper.com Cambridge, MA, USA
-