pipes for netrexx: examples

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

pipes for netrexx: examples

rvjansen

I realise there has not really been much attention to the new Pipes for NetRexx feature that is included in 3.07, so I'll try to give some examples. It is my intention that for people who are used to pipelines on CMS, it will show how they really look a lot like what you're accustomed to, and for those who not, that it is really cool technology.

Imagine you have landed a job as programmer guy or girl in an accountants firm and on your first day there is a question about backups; the backup takes too long. There is an urgent needs to identify the files that are produced on this day. You know how to this, of course, it is only some 20 lines of code; use the File() API, fill a collection class (you are thinking of an ArrayList already), or a TreeMap to sort the File object on last modified date already, call an instance of the Calender class, run a comparison - get that compiled and test it a bit - an hour or so would be sufficient. Of course, you need to install the Java compiler, because all machines have Java nowadays, but just not the compiler.

But if you want to really impress people, you should type in a command line and be done with it. For this you can use NetRexx pipelines. Fortunately, you emailed the NetRexxF.jar to yourself so you save it on the machine, and you're in business right away; you add it to the classpath.

Your first pipeline command should just test the waters. You send a command into the pipeline, and get its output:

pipe "(newfiles sep |) command ls -laFTl | console"

As pipelines will be compiled, the name of the produced java .class is specified between parentheses, in this case the executable will be newfile.class; the ls command with the flags is the unix way to get a directory listing. In this case, we send the output into the pipeline, but as the last stage (called a pipe 'sink') occurs immediately after that, every line will be echoed on the console.

A number of lines like these will be displayed on the console:

-rw-r--r-- 1 rvjansen staff 112 Oct 9 14:28:25 2017 testwordlist.rex
-rw-r--r--@ 1 rvjansen staff 4188 Mar 28 13:38:07 2018 text.bxml
-rw-r--r-- 1 rvjansen staff 6639 Sep 19 17:00:03 2018 thex.rex
-rw-r--r-- 1 rvjansen staff 6034391 Oct 9 14:28:25 2017 tmp.tst
-rw-r--r-- 1 rvjansen staff 0 Oct 9 14:28:25 2017 tmpf1
-rw-r--r-- 1 rvjansen staff 0 Oct 9 14:28:25 2017 tmpf2
-rw-r--r--@ 1 rvjansen staff 33601 Mar 28 13:38:07 2018 trees.bxml
-rw-r--r-- 1 rvjansen staff 1171 Oct 9 14:28:25 2017 try.dot
-rw-r--r-- 1 rvjansen staff 32756 Oct 9 14:28:25 2017 try.png
-rw-r--r-- 1 rvjansen staff 7052 Oct 9 14:28:25 2017 try.svg
-rw-r--r--@ 1 rvjansen staff 1474 Oct 9 14:28:25 2017 unix.dot
-rw-r--r--@ 1 rvjansen staff 66531 Oct 9 14:28:25 2017 unix.png

You see straight away that the relevant info is not in the first columns, and not in consecutive columns; we want to know the date (whether it is today or not) and not the time. So we filter this out of every line with a 'spec' stage.

pipe "(newfiles sep |) command ls -laFTl | rexx specs 42-47 1 58-* 8 | console"

Oct 9 2017 testwordlist.rex
Mar 28 2018 text.bxml
Sep 19 2018 thex.rex
Oct 9 2017 tmp.tst
Oct 9 2017 tmpf1
Oct 9 2017 tmpf2
Mar 28 2018 trees.bxml
Oct 9 2017 try.dot
Oct 9 2017 try.png
Oct 9 2017 try.svg
Oct 9 2017 unix.dot
Oct 9 2017 unix.png

For the CMS users, the only two differences are the earlier mentioned pipe classname, and the rexx cast before specs (which is exactly the same). This is because the JVM handles in objects, and we need to make sure that the output of this stage is of type Rexx. 

We can easily sort this without a lot of programming:

pipe "(newfiles sep |) command ls -laFTl | rexx specs 42-47 1 58-* 8 | sort | console"

So what now comes out of the pipeline is sorted:

Oct 22 2018 DownloadFile.nrx
Oct 22 2018 sqltest.njp
Oct 25 2018 hello.class
Sep 19 2018 base64.rex
Sep 19 2018 qtime.rex
Sep 19 2018 testbase64.rex
Sep 19 2018 thex.rex
Sep 26 2018 cps.exec
Sep 26 2018 rexxcps.rex*
Sep 29 2016 db2conn.rexx
Sep 29 2016 db2query.rexx
Sep 29 2016 invdsnutil.rexx
Sep 29 2016 rvjcmf01.panel
Sep 29 2016 rvjcmf01.rexx
Sep 29 2016 rvjcmf01.skel
Sep 29 2018 rexxtest.exec

But this is a bit funny, we would like to see chronological order of course, so we switch around some columns with another specs stage:

pipe "(newfiles sep |) command ls -laFTl | rexx specs 42-47 1 58-* 8 |  specs 7-11 1 1-6 7 12-* 12 | sort | console"

2018 Oct 2 hello.class
2018 Oct 2 sqltest.njp
2018 Sep 1 base64.rex
2018 Sep 1 qtime.rex
2018 Sep 1 testbase64.rex
2018 Sep 1 thex.rex
2018 Sep 2 cps.exec
2018 Sep 2 rexxcps.rex*
2018 Sep 2 rexxtest.exec

which is very near to what we want. Only thing to do now is to filter on the date. We use the strfind stage and hardcode the date for now. Let's say it is the 2nd of March, 2019:

pipe "(newfiles sep |) command ls -laFTl | rexx specs 42-47 1 58-* 8 |  specs 7-11 1 1-6 7 12-* 12 | strfind ' 2019 Mar 2' | sort | console"

Voila, you have impressed the accountants and now they now there is nothing to this programming thing. Be sure to sit on it for a while and not raise the expectations too high.

But seriously, everything you need for this example is already in NetRexx 3.07. All example commandlines work as-is,  but normally, you would specify your pipeline in a file and use so-called portait mode:

commandtest.njp:

pipe (newfiles sep |)

command ls -laFTl |
rexx specs 42-47 1 58-* 8 |
specs 7-11 1 1-6 7 12-* 12 |
sort |
strfind ' 2019 Mar 2' |
console

The filename is different from the generated class file name, on purpose. You could, and would, put different related pipelines in one file.

We added the sep option, it is normally ! (exclamation mark) instead of | (pipe), for historical reasons on different shells. But I like pipe.

Then I do a:

pipe commandtest && newfiles.class

but I have a gizmo that runs java classes automatically, you can just as well specify:

java newfiles

If you are on Windows, you can run cmd /c instead of the command stage. If your shell cannot find the pipe command, you should make one, it should call 

java org.netrexx.njpipes.pipes.compiler

I hope you enjoyed this little example, and I hope the VM people will have recognized a lot of this. Next example will be: “How to write a pipe filter stage in NetRexx.” We will also do some file I/O in there.


best regards,

René Jansen.



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: pipes for netrexx: examples

jlturriff
On 2019-03-23 03:17:49 René Jansen wrote:

> I realise there has not really been much attention to the new Pipes for
> NetRexx feature that is included in 3.07, so I'll try to give some
> examples. It is my intention that for people who are used to pipelines on
> CMS, it will show how they really look a lot like what you're accustomed
> to, and for those who not, that it is really cool technology. Imagine you
> have landed a job as programmer guy or girl in an accountants firm and on
> your first day there is a question about backups; the backup takes too
> long. There is an urgent needs to identify the files that are produced on
> this day. You know how to this, of course, it is only some 20 lines of
> code; use the File() API, fill a collection class (you are thinking of an
> ArrayList already), or a TreeMap to sort the File object on last modified
> date already, call an instance of the Calender class, run a comparison -
> get that compiled and test it a bit - an hour or so would be sufficient. Of
> course, you need to install the Java compiler, because all machines have
> Java nowadays, but just not the compiler. But if you want to really impress
> people, you should type in a command line and be done with it. For this you
> can use NetRexx pipelines. Fortunately, you emailed the NetRexxF.jar to
> yourself so you save it on the machine, and you're in business right away;
> you add it to the classpath. Your first pipeline command should just test
> the waters. You send a command into the pipeline, and get its output: pipe
> "(newfiles sep |) command ls -laFTl | console"
> As pipelines will be compiled, the name of the produced java .class is
> specified between parentheses, in this case the executable will be
> newfile.class; the ls command with the flags is the unix way to get a
> directory listing. In this case, we send the output into the pipeline, but
> as the last stage (called a pipe 'sink') occurs immediately after that,
> every line will be echoed on the console. A number of lines like these will
> be displayed on the console:
> -rw-r--r-- 1 rvjansen staff 112 Oct 9 14:28:25 2017 testwordlist.rex
> -rw-r--r--@ 1 rvjansen staff 4188 Mar 28 13:38:07 2018 text.bxml
> -rw-r--r-- 1 rvjansen staff 6639 Sep 19 17:00:03 2018 thex.rex
> -rw-r--r-- 1 rvjansen staff 6034391 Oct 9 14:28:25 2017 tmp.tst
> -rw-r--r-- 1 rvjansen staff 0 Oct 9 14:28:25 2017 tmpf1
> -rw-r--r-- 1 rvjansen staff 0 Oct 9 14:28:25 2017 tmpf2
> -rw-r--r--@ 1 rvjansen staff 33601 Mar 28 13:38:07 2018 trees.bxml
> -rw-r--r-- 1 rvjansen staff 1171 Oct 9 14:28:25 2017 try.dot
> -rw-r--r-- 1 rvjansen staff 32756 Oct 9 14:28:25 2017 try.png
> -rw-r--r-- 1 rvjansen staff 7052 Oct 9 14:28:25 2017 try.svg
> -rw-r--r--@ 1 rvjansen staff 1474 Oct 9 14:28:25 2017 unix.dot
> -rw-r--r--@ 1 rvjansen staff 66531 Oct 9 14:28:25 2017 unix.png
> You see straight away that the relevant info is not in the first columns,
> and not in consecutive columns; we want to know the date (whether it is
> today or not) and not the time. So we filter this out of every line with a
> 'spec' stage. pipe "(newfiles sep |) command ls -laFTl | rexx specs 42-47 1
> 58-* 8 | console" Oct 9 2017 testwordlist.rex
> Mar 28 2018 text.bxml
> Sep 19 2018 thex.rex
> Oct 9 2017 tmp.tst
> Oct 9 2017 tmpf1
> Oct 9 2017 tmpf2
> Mar 28 2018 trees.bxml
> Oct 9 2017 try.dot
> Oct 9 2017 try.png
> Oct 9 2017 try.svg
> Oct 9 2017 unix.dot
> Oct 9 2017 unix.png
> For the CMS users, the only two differences are the earlier mentioned pipe
> classname, and the rexx cast before specs (which is exactly the same). This
> is because the JVM handles in objects, and we need to make sure that the
> output of this stage is of type Rexx. We can easily sort this without a lot
> of programming:
> pipe "(newfiles sep |) command ls -laFTl | rexx specs 42-47 1 58-* 8 | sort
> | console" So what now comes out of the pipeline is sorted:
> Oct 22 2018 DownloadFile.nrx
> Oct 22 2018 sqltest.njp
> Oct 25 2018 hello.class
> Sep 19 2018 base64.rex
> Sep 19 2018 qtime.rex
> Sep 19 2018 testbase64.rex
> Sep 19 2018 thex.rex
> Sep 26 2018 cps.exec
> Sep 26 2018 rexxcps.rex*
> Sep 29 2016 db2conn.rexx
> Sep 29 2016 db2query.rexx
> Sep 29 2016 invdsnutil.rexx
> Sep 29 2016 rvjcmf01.panel
> Sep 29 2016 rvjcmf01.rexx
> Sep 29 2016 rvjcmf01.skel
> Sep 29 2018 rexxtest.exec
> But this is a bit funny, we would like to see chronological order of
> course, so we switch around some columns with another specs stage: pipe
> "(newfiles sep |) command ls -laFTl | rexx specs 42-47 1 58-* 8 |  specs
> 7-11 1 1-6 7 12-* 12 | sort | console" 2018 Oct 2 hello.class
> 2018 Oct 2 sqltest.njp
> 2018 Sep 1 base64.rex
> 2018 Sep 1 qtime.rex
> 2018 Sep 1 testbase64.rex
> 2018 Sep 1 thex.rex
> 2018 Sep 2 cps.exec
> 2018 Sep 2 rexxcps.rex*
> 2018 Sep 2 rexxtest.exec
> which is very near to what we want. Only thing to do now is to filter on
> the date. We use the strfind stage and hardcode the date for now. Let's say
> it is the 2nd of March, 2019: pipe "(newfiles sep |) command ls -laFTl |
> rexx specs 42-47 1 58-* 8 |  specs 7-11 1 1-6 7 12-* 12 | strfind ' 2019
> Mar 2' | sort | console" Voila, you have impressed the accountants and now
> they now there is nothing to this programming thing. Be sure to sit on it
> for a while and not raise the expectations too high. But seriously,
> everything you need for this example is already in NetRexx 3.07. All
> example commandlines work as-is,  but normally, you would specify your
> pipeline in a file and use so-called portait mode: commandtest.njp:
> pipe (newfiles sep |)
> command ls -laFTl |
> rexx specs 42-47 1 58-* 8 |
> specs 7-11 1 1-6 7 12-* 12 |
> sort |
> strfind ' 2019 Mar 2' |
> console
> The filename is different from the generated class file name, on purpose.
> You could, and would, put different related pipelines in one file. We added
> the sep option, it is normally ! (exclamation mark) instead of | (pipe),
> for historical reasons on different shells. But I like pipe. Then I do a:
> pipe commandtest && newfiles.class
> but I have a gizmo that runs java classes automatically, you can just as
> well specify: java newfiles
> If you are on Windows, you can run cmd /c instead of the command stage. If
> your shell cannot find the pipe command, you should make one, it should
> call java org.netrexx.njpipes.pipes.compiler
> I hope you enjoyed this little example, and I hope the VM people will have
> recognized a lot of this. Next example will be: “How to write a pipe filter
> stage in NetRexx.” We will also do some file I/O in there.
>
> best regards,
> René Jansen.

        This looks very nice.  Will there eventually be a version that does
multi-stream pipelines the way CMS/TSO Pipelines does?  That's what is really
missing from the Unix native pipe facility.

Leslie

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: pipes for netrexx: examples

rvjansen
Well it does already. This was just a simple example. It gets better!

René.

> On 24 Mar 2019, at 11:36, J Leslie Turriff <[hidden email]> wrote:
>
>> On 2019-03-23 03:17:49 René Jansen wrote:
>> I realise there has not really been much attention to the new Pipes for
>> NetRexx feature that is included in 3.07, so I'll try to give some
>> examples. It is my intention that for people who are used to pipelines on
>> CMS, it will show how they really look a lot like what you're accustomed
>> to, and for those who not, that it is really cool technology. Imagine you
>> have landed a job as programmer guy or girl in an accountants firm and on
>> your first day there is a question about backups; the backup takes too
>> long. There is an urgent needs to identify the files that are produced on
>> this day. You know how to this, of course, it is only some 20 lines of
>> code; use the File() API, fill a collection class (you are thinking of an
>> ArrayList already), or a TreeMap to sort the File object on last modified
>> date already, call an instance of the Calender class, run a comparison -
>> get that compiled and test it a bit - an hour or so would be sufficient. Of
>> course, you need to install the Java compiler, because all machines have
>> Java nowadays, but just not the compiler. But if you want to really impress
>> people, you should type in a command line and be done with it. For this you
>> can use NetRexx pipelines. Fortunately, you emailed the NetRexxF.jar to
>> yourself so you save it on the machine, and you're in business right away;
>> you add it to the classpath. Your first pipeline command should just test
>> the waters. You send a command into the pipeline, and get its output: pipe
>> "(newfiles sep |) command ls -laFTl | console"
>> As pipelines will be compiled, the name of the produced java .class is
>> specified between parentheses, in this case the executable will be
>> newfile.class; the ls command with the flags is the unix way to get a
>> directory listing. In this case, we send the output into the pipeline, but
>> as the last stage (called a pipe 'sink') occurs immediately after that,
>> every line will be echoed on the console. A number of lines like these will
>> be displayed on the console:
>> -rw-r--r-- 1 rvjansen staff 112 Oct 9 14:28:25 2017 testwordlist.rex
>> -rw-r--r--@ 1 rvjansen staff 4188 Mar 28 13:38:07 2018 text.bxml
>> -rw-r--r-- 1 rvjansen staff 6639 Sep 19 17:00:03 2018 thex.rex
>> -rw-r--r-- 1 rvjansen staff 6034391 Oct 9 14:28:25 2017 tmp.tst
>> -rw-r--r-- 1 rvjansen staff 0 Oct 9 14:28:25 2017 tmpf1
>> -rw-r--r-- 1 rvjansen staff 0 Oct 9 14:28:25 2017 tmpf2
>> -rw-r--r--@ 1 rvjansen staff 33601 Mar 28 13:38:07 2018 trees.bxml
>> -rw-r--r-- 1 rvjansen staff 1171 Oct 9 14:28:25 2017 try.dot
>> -rw-r--r-- 1 rvjansen staff 32756 Oct 9 14:28:25 2017 try.png
>> -rw-r--r-- 1 rvjansen staff 7052 Oct 9 14:28:25 2017 try.svg
>> -rw-r--r--@ 1 rvjansen staff 1474 Oct 9 14:28:25 2017 unix.dot
>> -rw-r--r--@ 1 rvjansen staff 66531 Oct 9 14:28:25 2017 unix.png
>> You see straight away that the relevant info is not in the first columns,
>> and not in consecutive columns; we want to know the date (whether it is
>> today or not) and not the time. So we filter this out of every line with a
>> 'spec' stage. pipe "(newfiles sep |) command ls -laFTl | rexx specs 42-47 1
>> 58-* 8 | console" Oct 9 2017 testwordlist.rex
>> Mar 28 2018 text.bxml
>> Sep 19 2018 thex.rex
>> Oct 9 2017 tmp.tst
>> Oct 9 2017 tmpf1
>> Oct 9 2017 tmpf2
>> Mar 28 2018 trees.bxml
>> Oct 9 2017 try.dot
>> Oct 9 2017 try.png
>> Oct 9 2017 try.svg
>> Oct 9 2017 unix.dot
>> Oct 9 2017 unix.png
>> For the CMS users, the only two differences are the earlier mentioned pipe
>> classname, and the rexx cast before specs (which is exactly the same). This
>> is because the JVM handles in objects, and we need to make sure that the
>> output of this stage is of type Rexx. We can easily sort this without a lot
>> of programming:
>> pipe "(newfiles sep |) command ls -laFTl | rexx specs 42-47 1 58-* 8 | sort
>> | console" So what now comes out of the pipeline is sorted:
>> Oct 22 2018 DownloadFile.nrx
>> Oct 22 2018 sqltest.njp
>> Oct 25 2018 hello.class
>> Sep 19 2018 base64.rex
>> Sep 19 2018 qtime.rex
>> Sep 19 2018 testbase64.rex
>> Sep 19 2018 thex.rex
>> Sep 26 2018 cps.exec
>> Sep 26 2018 rexxcps.rex*
>> Sep 29 2016 db2conn.rexx
>> Sep 29 2016 db2query.rexx
>> Sep 29 2016 invdsnutil.rexx
>> Sep 29 2016 rvjcmf01.panel
>> Sep 29 2016 rvjcmf01.rexx
>> Sep 29 2016 rvjcmf01.skel
>> Sep 29 2018 rexxtest.exec
>> But this is a bit funny, we would like to see chronological order of
>> course, so we switch around some columns with another specs stage: pipe
>> "(newfiles sep |) command ls -laFTl | rexx specs 42-47 1 58-* 8 |  specs
>> 7-11 1 1-6 7 12-* 12 | sort | console" 2018 Oct 2 hello.class
>> 2018 Oct 2 sqltest.njp
>> 2018 Sep 1 base64.rex
>> 2018 Sep 1 qtime.rex
>> 2018 Sep 1 testbase64.rex
>> 2018 Sep 1 thex.rex
>> 2018 Sep 2 cps.exec
>> 2018 Sep 2 rexxcps.rex*
>> 2018 Sep 2 rexxtest.exec
>> which is very near to what we want. Only thing to do now is to filter on
>> the date. We use the strfind stage and hardcode the date for now. Let's say
>> it is the 2nd of March, 2019: pipe "(newfiles sep |) command ls -laFTl |
>> rexx specs 42-47 1 58-* 8 |  specs 7-11 1 1-6 7 12-* 12 | strfind ' 2019
>> Mar 2' | sort | console" Voila, you have impressed the accountants and now
>> they now there is nothing to this programming thing. Be sure to sit on it
>> for a while and not raise the expectations too high. But seriously,
>> everything you need for this example is already in NetRexx 3.07. All
>> example commandlines work as-is,  but normally, you would specify your
>> pipeline in a file and use so-called portait mode: commandtest.njp:
>> pipe (newfiles sep |)
>> command ls -laFTl |
>> rexx specs 42-47 1 58-* 8 |
>> specs 7-11 1 1-6 7 12-* 12 |
>> sort |
>> strfind ' 2019 Mar 2' |
>> console
>> The filename is different from the generated class file name, on purpose.
>> You could, and would, put different related pipelines in one file. We added
>> the sep option, it is normally ! (exclamation mark) instead of | (pipe),
>> for historical reasons on different shells. But I like pipe. Then I do a:
>> pipe commandtest && newfiles.class
>> but I have a gizmo that runs java classes automatically, you can just as
>> well specify: java newfiles
>> If you are on Windows, you can run cmd /c instead of the command stage. If
>> your shell cannot find the pipe command, you should make one, it should
>> call java org.netrexx.njpipes.pipes.compiler
>> I hope you enjoyed this little example, and I hope the VM people will have
>> recognized a lot of this. Next example will be: “How to write a pipe filter
>> stage in NetRexx.” We will also do some file I/O in there.
>>
>> best regards,
>> René Jansen.
>
>    This looks very nice.  Will there eventually be a version that does
> multi-stream pipelines the way CMS/TSO Pipelines does?  That's what is really
> missing from the Unix native pipe facility.
>
> Leslie
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
> Online Archive : https://urldefense.proofpoint.com/v2/url?u=http-3A__ibm-2Dnetrexx.215625.n3.nabble.com_&d=DwIFaQ&c=jf_iaSHvJObTbx-siA1ZOg&r=_6rXNpPJ1fYV-3bV1za02NiR4PUelvicfHXwtnTXpXE&m=2Rz2f0_3jJA0CTSWg_5vDe8LKL_4NoAYP0sUjwYOwFA&s=oHSnWXWwvlSs5T4TM8JiFK61FEItWxIrem1PRSCEt7o&e=
>


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: pipes for netrexx: examples

jlturriff
On 2019-03-24 10:49:58 René Jansen wrote:
> Well it does already. This was just a simple example. It gets better!
>
> René.

        Wonderful.  I'll take a closer look.  Thank you, René.

Leslie

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: pipes for netrexx: examples

George Hovey-2
In reply to this post by rvjansen
Touché René!

On Sun, Mar 24, 2019 at 11:50 AM René Jansen <[hidden email]> wrote:
Well it does already. This was just a simple example. It gets better!

René.

> On 24 Mar 2019, at 11:36, J Leslie Turriff <[hidden email]> wrote:
>
>> On 2019-03-23 03:17:49 René Jansen wrote:
>> I realise there has not really been much attention to the new Pipes for
>> NetRexx feature that is included in 3.07, so I'll try to give some
>> examples. It is my intention that for people who are used to pipelines on
>> CMS, it will show how they really look a lot like what you're accustomed
>> to, and for those who not, that it is really cool technology. Imagine you
>> have landed a job as programmer guy or girl in an accountants firm and on
>> your first day there is a question about backups; the backup takes too
>> long. There is an urgent needs to identify the files that are produced on
>> this day. You know how to this, of course, it is only some 20 lines of
>> code; use the File() API, fill a collection class (you are thinking of an
>> ArrayList already), or a TreeMap to sort the File object on last modified
>> date already, call an instance of the Calender class, run a comparison -
>> get that compiled and test it a bit - an hour or so would be sufficient. Of
>> course, you need to install the Java compiler, because all machines have
>> Java nowadays, but just not the compiler. But if you want to really impress
>> people, you should type in a command line and be done with it. For this you
>> can use NetRexx pipelines. Fortunately, you emailed the NetRexxF.jar to
>> yourself so you save it on the machine, and you're in business right away;
>> you add it to the classpath. Your first pipeline command should just test
>> the waters. You send a command into the pipeline, and get its output: pipe
>> "(newfiles sep |) command ls -laFTl | console"
>> As pipelines will be compiled, the name of the produced java .class is
>> specified between parentheses, in this case the executable will be
>> newfile.class; the ls command with the flags is the unix way to get a
>> directory listing. In this case, we send the output into the pipeline, but
>> as the last stage (called a pipe 'sink') occurs immediately after that,
>> every line will be echoed on the console. A number of lines like these will
>> be displayed on the console:
>> -rw-r--r-- 1 rvjansen staff 112 Oct 9 14:28:25 2017 testwordlist.rex
>> -rw-r--r--@ 1 rvjansen staff 4188 Mar 28 13:38:07 2018 text.bxml
>> -rw-r--r-- 1 rvjansen staff 6639 Sep 19 17:00:03 2018 thex.rex
>> -rw-r--r-- 1 rvjansen staff 6034391 Oct 9 14:28:25 2017 tmp.tst
>> -rw-r--r-- 1 rvjansen staff 0 Oct 9 14:28:25 2017 tmpf1
>> -rw-r--r-- 1 rvjansen staff 0 Oct 9 14:28:25 2017 tmpf2
>> -rw-r--r--@ 1 rvjansen staff 33601 Mar 28 13:38:07 2018 trees.bxml
>> -rw-r--r-- 1 rvjansen staff 1171 Oct 9 14:28:25 2017 try.dot
>> -rw-r--r-- 1 rvjansen staff 32756 Oct 9 14:28:25 2017 try.png
>> -rw-r--r-- 1 rvjansen staff 7052 Oct 9 14:28:25 2017 try.svg
>> -rw-r--r--@ 1 rvjansen staff 1474 Oct 9 14:28:25 2017 unix.dot
>> -rw-r--r--@ 1 rvjansen staff 66531 Oct 9 14:28:25 2017 unix.png
>> You see straight away that the relevant info is not in the first columns,
>> and not in consecutive columns; we want to know the date (whether it is
>> today or not) and not the time. So we filter this out of every line with a
>> 'spec' stage. pipe "(newfiles sep |) command ls -laFTl | rexx specs 42-47 1
>> 58-* 8 | console" Oct 9 2017 testwordlist.rex
>> Mar 28 2018 text.bxml
>> Sep 19 2018 thex.rex
>> Oct 9 2017 tmp.tst
>> Oct 9 2017 tmpf1
>> Oct 9 2017 tmpf2
>> Mar 28 2018 trees.bxml
>> Oct 9 2017 try.dot
>> Oct 9 2017 try.png
>> Oct 9 2017 try.svg
>> Oct 9 2017 unix.dot
>> Oct 9 2017 unix.png
>> For the CMS users, the only two differences are the earlier mentioned pipe
>> classname, and the rexx cast before specs (which is exactly the same). This
>> is because the JVM handles in objects, and we need to make sure that the
>> output of this stage is of type Rexx. We can easily sort this without a lot
>> of programming:
>> pipe "(newfiles sep |) command ls -laFTl | rexx specs 42-47 1 58-* 8 | sort
>> | console" So what now comes out of the pipeline is sorted:
>> Oct 22 2018 DownloadFile.nrx
>> Oct 22 2018 sqltest.njp
>> Oct 25 2018 hello.class
>> Sep 19 2018 base64.rex
>> Sep 19 2018 qtime.rex
>> Sep 19 2018 testbase64.rex
>> Sep 19 2018 thex.rex
>> Sep 26 2018 cps.exec
>> Sep 26 2018 rexxcps.rex*
>> Sep 29 2016 db2conn.rexx
>> Sep 29 2016 db2query.rexx
>> Sep 29 2016 invdsnutil.rexx
>> Sep 29 2016 rvjcmf01.panel
>> Sep 29 2016 rvjcmf01.rexx
>> Sep 29 2016 rvjcmf01.skel
>> Sep 29 2018 rexxtest.exec
>> But this is a bit funny, we would like to see chronological order of
>> course, so we switch around some columns with another specs stage: pipe
>> "(newfiles sep |) command ls -laFTl | rexx specs 42-47 1 58-* 8 |  specs
>> 7-11 1 1-6 7 12-* 12 | sort | console" 2018 Oct 2 hello.class
>> 2018 Oct 2 sqltest.njp
>> 2018 Sep 1 base64.rex
>> 2018 Sep 1 qtime.rex
>> 2018 Sep 1 testbase64.rex
>> 2018 Sep 1 thex.rex
>> 2018 Sep 2 cps.exec
>> 2018 Sep 2 rexxcps.rex*
>> 2018 Sep 2 rexxtest.exec
>> which is very near to what we want. Only thing to do now is to filter on
>> the date. We use the strfind stage and hardcode the date for now. Let's say
>> it is the 2nd of March, 2019: pipe "(newfiles sep |) command ls -laFTl |
>> rexx specs 42-47 1 58-* 8 |  specs 7-11 1 1-6 7 12-* 12 | strfind ' 2019
>> Mar 2' | sort | console" Voila, you have impressed the accountants and now
>> they now there is nothing to this programming thing. Be sure to sit on it
>> for a while and not raise the expectations too high. But seriously,
>> everything you need for this example is already in NetRexx 3.07. All
>> example commandlines work as-is,  but normally, you would specify your
>> pipeline in a file and use so-called portait mode: commandtest.njp:
>> pipe (newfiles sep |)
>> command ls -laFTl |
>> rexx specs 42-47 1 58-* 8 |
>> specs 7-11 1 1-6 7 12-* 12 |
>> sort |
>> strfind ' 2019 Mar 2' |
>> console
>> The filename is different from the generated class file name, on purpose.
>> You could, and would, put different related pipelines in one file. We added
>> the sep option, it is normally ! (exclamation mark) instead of | (pipe),
>> for historical reasons on different shells. But I like pipe. Then I do a:
>> pipe commandtest && newfiles.class
>> but I have a gizmo that runs java classes automatically, you can just as
>> well specify: java newfiles
>> If you are on Windows, you can run cmd /c instead of the command stage. If
>> your shell cannot find the pipe command, you should make one, it should
>> call java org.netrexx.njpipes.pipes.compiler
>> I hope you enjoyed this little example, and I hope the VM people will have
>> recognized a lot of this. Next example will be: “How to write a pipe filter
>> stage in NetRexx.” We will also do some file I/O in there.
>>
>> best regards,
>> René Jansen.
>
>    This looks very nice.  Will there eventually be a version that does
> multi-stream pipelines the way CMS/TSO Pipelines does?  That's what is really
> missing from the Unix native pipe facility.
>
> Leslie
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
> Online Archive : https://urldefense.proofpoint.com/v2/url?u=http-3A__ibm-2Dnetrexx.215625.n3.nabble.com_&d=DwIFaQ&c=jf_iaSHvJObTbx-siA1ZOg&r=_6rXNpPJ1fYV-3bV1za02NiR4PUelvicfHXwtnTXpXE&m=2Rz2f0_3jJA0CTSWg_5vDe8LKL_4NoAYP0sUjwYOwFA&s=oHSnWXWwvlSs5T4TM8JiFK61FEItWxIrem1PRSCEt7o&e=
>


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



--
"Life isn't one damn thing after another -- it's the same damn thing over and over."
  -- Edna St Vincent Millay

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/