For Programmers: Free Programming Magazines  


Home > Archive > Rexx > January 2008 > Reading stuff piped to my program









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Reading stuff piped to my program
Steve Swift

2008-01-22, 4:39 am

If I have a rexx program called "thing" that runs when I execute the
"thing" command in my Windows XP, what code should I use inside "thing"
to read the data piped to "thing" when I issue the command:

dir|thing

I've tried:
Queued() and Parse pull
Lines() and linein()
Chars() and charin() (with "", STDIN and even, in desperation, STDOUT)

but with no success so far. I've run out of inspiration where the data
might be.

Just in case I get this working, let me predict my next question: Do I
need to do anything to pass data to a subsequent stage in a pipeline
other than writing to STDOUT?

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Rick McGuire

2008-01-22, 8:27 am

Without seeing what you have tried, it's difficult to guess what might
be going wrong. Here's a very simple pipe stage I wrote that works just
fine for me:

signal on notready

do forever
say linein()~reverse
end

notready:

Have you been able to verify that your stage is even getting invoked?
I've only gotten this to work by explicitly specifying the rexx command
on the pipe stage. It appears the shell pipe stage resolution is not as
sophisticated as simple command resolution.

type some.file | rexx reverser.rex

Rick


Steve Swift wrote:
> If I have a rexx program called "thing" that runs when I execute the
> "thing" command in my Windows XP, what code should I use inside "thing"
> to read the data piped to "thing" when I issue the command:
>
> dir|thing
>
> I've tried:
> Queued() and Parse pull
> Lines() and linein()
> Chars() and charin() (with "", STDIN and even, in desperation, STDOUT)
>
> but with no success so far. I've run out of inspiration where the data
> might be.
>
> Just in case I get this working, let me predict my next question: Do I
> need to do anything to pass data to a subsequent stage in a pipeline
> other than writing to STDOUT?
>

Steve Swift

2008-01-22, 8:27 am

Rick McGuire wrote:
> Have you been able to verify that your stage is even getting invoked?
>
>

Yes, a side effect of my stage is that it copies the data to a file in
my temp directory. They get created, but are empty.

> Have you been able to verify that your stage is even getting invoked?
> I've only gotten this to work by explicitly specifying the rexx
> command on the pipe stage.


Aha! That was the touchstone! "dir|browse" ran my code, but didn't
connect STDIN. "dir|rexx browse.rex" worked a treat. I'll probably get
around this with a browse.bat "wrapper". Or I could write the entire
stage as a bat program (yuck!).

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Steve Swift

2008-01-22, 8:27 am

Steve Swift wrote:
> I'll probably get around this with a browse.bat "wrapper".


Here is my super-complex browse.bat :

@ECHO OFF
rexx.exe browse.rex


So now I can use: dir|browse

Thanks!

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Michael Lueck

2008-01-22, 7:35 pm

Greetings Steve-

On the note about pipes, reminded me that I opened a bug against ooRexx in the area of pipes.

[ 1116850 ] Win32 STDOUT unable to be piped to another program
https://sourceforge.net/tracker/ind...701&atid=684730

On all ooRexx platforms, I have the systems configured to run ooRexx programs by simply entering "program.rex" without the interpreter. On Linux I use the shabang, and on Windows .rex files are
associated with the interpreter. I do not add the .rex extension to the list of extensions Windows will search through... consistent between platforms that I enter "program.rex" on either platform.

--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/
Steve Swift

2008-01-22, 7:35 pm

Michael Lueck wrote:
> On the note about pipes, reminded me that I opened a bug against
> ooRexx in the area of pipes.
>
> [ 1116850 ] Win32 STDOUT unable to be piped to another program
> https://sourceforge.net/tracker/ind...701&atid=684730


My experience is that it is the STDIN in the (piped) rexx that is
failing, as "dir|browse" fails if the "browse" stage is the only REXX
involved.

> I do not add the .rex extension to the list of extensions Windows
> will search through... consistent between platforms that I enter
> "program.rex" on either platform.


I drove my consistency the other way, I added "rex" to my Windows
PATHEXT for consistency with VM/370 where BROWSE EXEC A could be
executed simply by "browse".

On linux, I create the file simply as "browse" since the shebang takes
care of launching rexx. This is especially useful for my CGI scripts
which look better in a URL such as http://host/cgi-bin/routine (rather
than routine.rex which gives away the language my script is written in,
perhaps).

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Michael Lueck

2008-01-22, 7:35 pm

Steve Swift wrote:
> I drove my consistency the other way...


Extensionless files present challenges to SlickEdit as the extension determines the color coding and what not.

And too, I did not want to fiddle around with renaming files.

The FWIW Dept.

--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/
Steve Swift

2008-01-23, 4:35 am

> Extensionless files present challenges to SlickEdit as the extension
> determines the color coding and what not.


That's where I'm lucky with EditPadPro - you can specify a regex to be
used against line 1 to enhance the filetype recognition. So it
recognises shebangs that contain "rexx".

--
Steve Swift (The other member of the FWIW Dept)
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com