Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Regina on unix
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 21st June 01:37
richgr
External User
 
Posts: 1
Default Regina on unix


I am a heavy user of rexx on VM/CMS, and now have been given a rexx
project on a NetBSD host. The admins are going to install the current
(3.2?) Regina for me and I just have two questions for the gurus.

Whats the best way to run a unix command and get access to the output
(stdout) of the command. I know I can redirect it to a disk file and
read the file. Is there a better way?

For reading and writing files, is linein() and lineout() the preferred way?
The files I will be reading/writing are text files that have linends.

Thanks.

--
Rich Greenberg Work: Rich.Greenberg atsign worldspan.com + 1 770 563 6656
N6LRT Marietta, GA, USA Play: richgr atsign panix.com + 1 770 321 6507
Eastern time zone. I speak for myself & my dogs only. VM'er since CP-67
Canines:Val(Chinook,CGC,TT), Red & Shasta(Husky,(RIP)) Owner:Chinook-L
Atlanta Siberian Husky Rescue. http://www.panix.com/~richgr/ Asst Owner:Sibernet-L
  Reply With Quote


  sponsored links


2 21st June 01:37
florian_große-coosmann
External User
 
Posts: 1
Default Regina on unix


Hi Rich,

Rich Greenberg schrieb:


Use ADDRESS. If you know that the command is an external one, you can use
ADDRESS COMMAND.
Otherwise you may use ADDRESS SYSTEM, you have to do so for shell builtins
or shell processing.

You can choose the preferred output. It may be either a STREAM, a STEM
or a FIFO or LIFO, e.g.

ADDRESS COMMAND "ls" WITH OUTPUT STEM out.

You have to use a dot after a stem's name. streams or queues are accepted
both as symbols or as strings.
Additionally you can redirect INPUT and ERROR in a command, e.g.

ADDRESS COMMAND "sort" WITH INPUT STREAM "data" OUTPUT STREAM "data" ERROR STEM crash.

(Regina handles this case properly without destruction of data.)
You can add the keywords APPEND or REPLACE immediately following OUTPUT or ERROR.
The default is REPLACE.

The fastest kind of IO redirection are LIFOs and FIFOs. The current queue is
addressed by the empty string. Other queue names are possible.

Yes.

Cheers, Florian
  Reply With Quote
3 21st June 01:37
anthony borla
External User
 
Posts: 1
Default Regina on unix


Under *NIX you use one of several shells [i.e. command interpreters] to
launch 'commands', which can be binary executeable files, or shell scripts,
text files which contain series of commands.

Command use, whether interactively, or via a script, sees 'stdin' and
'stdout' default to the console i.e. all input is expected from, and all
output directed to, the console. You may alter this behaviour via:

* File Redirection i.e. direct 'stdout' to a file, accept 'stdin'
from a file

* Piping i.e. pipe the 'stdout' of a command directly as the
'stdin' of another, thus avoiding the creation of temporary
files

Both these tasks can be performed without altering the original commands in
any way, and may be done so interatively, or in a shell script. Examples:

# 'command' would probably expect input from 'stdin',
# and redirect output to 'stdout'
command

# Input now taken from 'infile', and output directed to
# 'outfile' via 'file redirection', all without altering # 'command's internals
command < infile > outfile

# Output of 'command1' piped to 'command2', which then
# pipes its output to 'command3' which then redirects it
# to file, 'outfile'
command1 | command2 | command3 > outfile

Needless to say, all these techniques are 'REXX-accessable' by issuing the
relevant command strings. See below for a description of a, probably better, approach.


I'm not sure about the 'preferred' method for performing this task; the
BIF's you mention are certainly suited to this task of file-based,
line-oriented I/O. Other, more knowledgeable posters, may be able to address
questions of performance efficiency and the like.

Since, however, you will also be issuing *NIX shell commands from your REXX
scripts and:

* Feeding data to them
* Extracting data from them

an alternative to creating temporary files for such data exchange is to use
the REXX 'ADDRESS' instruction. It's use provides tremendous flexibility
since it allows data exhange with external commands not only via files, but
directly with stem variables, as well as the stack in either LIFO or FIFO
order.

The Regina do***entation offers a wealth of information, and useful examples
of, 'ADDRESS'.

I hope this helps.

Anthony Borla

P.S.

If you are a user of the IBM RexxUtil package, which includes handy routines
like 'sysCls', as well as various file management functions, you may wish to
obtain the RexxUtil for Regina package [RegUtil] from:

http://www.interlog.com/~ptjm
  Reply With Quote
4 21st June 01:37
imc
External User
 
Posts: 1
Default Regina on unix


According to Rich Greenberg in a posting to comp.lang.rexx:


Yes - use the ADDRESS ... WITH instruction which should be in the Regina
docs (it's an extension mandated by the ANSI committee and thus found in
the standards do***ent, but it isn't widely implemented; Regina does
have it, however).


As far as I know it's the preferred way.
--
---- Ian Collier : imc@comlab.ox.ac.uk : WWW page (including REXX section):
------ http://users.comlab.ox.ac.uk/ian.collier/imc.shtml

New to this group? Answers to frequently-asked questions can be had from
http://rexx.hursley.ibm.com/rexx/ .
  Reply With Quote
5 21st June 01:37
ptjm
External User
 
Posts: 1
Default Regina on unix


% Whats the best way to run a unix command and get access to the output
% (stdout) of the command.

In addition to using `address with', you could use the rxqueue command,
as in

'cmd | /usr/local/bin/rxqueue &'

you can then pull the data off the queue, as you might be used to. The
advantage of this is that if you manage to pull it off properly,
your command could be running in the background as you process its
output.

It does require some set-up, and Regina has a tendency to handle rxqueue
internally, and I believe it redirects the output to a file in the process,
so you need to be careful (in this case, I've typed the full path
to the command) (which then fails for me because I haven't got the
queue server running).

I have a library which provides functions to read to and write from the
standard input, output, and error of Unix commands. It's not needed for
most purposes now that `address with' is here, but I still use it
in cases when I want to process the output of a command while the command
is running. http://www.interlog.com/~ptjm/#rexxfile

--

Patrick TJ McPhee
East York Canada
ptjm@interlog.com
  Reply With Quote
6 21st June 01:38
thomas.schneider
External User
 
Posts: 1
Default Rexx on UNIX for VM/CMS users ...


Hello Rich,
when you are coming from VM/CMS, you may find my 'Rexx2Nrx' approach
useful.
Rexx2Nrx does allow you to run your Rexx programs on any Java Virtual
machine.
Rexx2Nrx is upwards compatible to IBM classic Rexx, and the IBM REXX
compiler as well (ie. it DOES support /*%INCLUDED files */).

You will find details on my home-page http://www.Rexx2Nrx.com

kind regards, Tom (http://www.Rexx2Nrx.com).
  Reply With Quote
7 21st June 01:38
shmuel (seymour j.) metz
External User
 
Posts: 1
Default Regina on unix


In <s7WQb.27713$Wa.6544@news-server.bigpond.net.au>, on 01/25/2004
at 09:00 PM, "Anthony Borla" <ajborla@bigpond.com> said:

From the wording of his question, he's probably aware of all of that.
Presumably the OUTPUT option of ADDRESS does what he wants.

--
Shmuel (Seymour J.) Metz, SysProg and JOAT

Unsolicited bulk E-mail will be subject to legal action. I reserve
the right to publicly post or ridicule any abusive E-mail.

Reply to domain Patriot dot net user shmuel+news to contact me. Do
not reply to spamtrap@library.lspace.org
  Reply With Quote
8 21st June 01:38
shmuel (seymour j.) metz
External User
 
Posts: 1
Default Regina on unix


In <bv18cr$8qs$1@online.de>, on 01/25/2004
at 09:19 PM, Florian Große-Coosmann
<florian@grosse-coosmann.germany> said:

Will that work if you've set a default value for the stem, or do you
have to use, e.g.,

ADDRESS COMMAND "ls" WITH OUTPUT STEM 'OUT.'

--
Shmuel (Seymour J.) Metz, SysProg and JOAT

Unsolicited bulk E-mail will be subject to legal action. I reserve
the right to publicly post or ridicule any abusive E-mail.

Reply to domain Patriot dot net user shmuel+news to contact me. Do
not reply to spamtrap@library.lspace.org
  Reply With Quote
9 29th June 03:01
imc
External User
 
Posts: 1
Default Regina on unix


A short while ago I became aware that Shmuel (Seymour J.) Metz had

According to the standard, the token after the word STEM is taken
literally. In fact, the standard doesn't even allow you to put quotes
round it. (As you know, the token after the word ADDRESS is also taken
literally, though you may put quotes round it if you wish.)
--
---- Ian Collier : imc@comlab.ox.ac.uk : WWW page (including REXX section):
------ http://users.comlab.ox.ac.uk/ian.collier/imc.shtml

New to this group? Answers to frequently-asked questions can be had from
http://rexx.hursley.ibm.com/rexx/ .
  Reply With Quote
10 29th June 03:01
florian_große-coosmann
External User
 
Posts: 1
Default Regina on unix


Hi,

Shmuel (Seymour J.) Metz schrieb:

A default value is not used on output and if you don't have APPEND
set. With APPEND out.0 is accessed before the command is issued.
This MAY be a default value.
A default value MAY be set when an INPUT stem is used.

In most cases a default value is useless or overkill for ADDRESS.
But it doesn't hurt.

Ian doesn't say that Regina is standard conforming here.
So the answer to the last part of the question is "no".

Cheers, Florian
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666