method Boilerplate(input_data) static signals IOException,InterruptedException;
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /* B O I L E R P L A T E */ /* Identifies program source et c. */ /* */ /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ say "input data were . . . . . " input_data ; parse source Name MethClass Source ; say Name '; ' MethClass '; ' Source ' . . .From parse source in BP , , , '; cmd = 'cmd /c dir "C:\\program files" ' say 'the command is . . . . . ' cmd; r = Runtime.getRuntime() p = r.exec(cmd) class StreamFiler extends Thread is=InputStream filename=String --34567890123456789012345678901234567890123456789 method StreamFiler(is2=InputStream, outputfilename=String) -- constructor method is = is2 method run() public -- a method that runs when the Thread object is started outputfilename='C:\\out_file.txt' -- outputfilename do br = BufferedReader(InputStreamReader(is)) -- create an object to read an output stream outfile = BufferedWriter(FileWriter(outputfilename)) -- create an object to write data to a file line=String null line = br.readLine -- read the first line loop while line \= null -- System.out.println(type ">" line) outfile.write(line,0,line.length) -- write input line to output file outfile.newLine -- advance file to next line line = br.readLine -- read a new input line end outfile.close -- close the file when done catch ioe=IOException -- intercept any io errors and print a trace ioe.printStackTrace() end The code above compiles and runs but does not produce an output file. BobH _______________________________________________ Ibm-netrexx mailing list [hidden email] |
Hi Bob,
several things: as it is now, it needs a method main(args=String[]) static to start running if you invoke it by the class name that is given by your source filename. The Boilerplate method is not called automatically. You will not need it, as the main method is called automatically on startup. It will provide the first argument to the program in args[0] - which can be used instead of your input_data. If I have some time tonight I will try to make it run with the thread reading the stream - if no one beats me to it. best regards, René _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by Robert L Hamilton
Runtime.getRuntime().exec needs an array.
In your (Windows) case : execArray[0] = 'cmd.exe" execArray[1] = "/c" execArray[2] = 'dir "C:\\program files"' I use the following method : method rxExecArray(execArray = String[]) private do p = Runtime.getRuntime().exec(execArray) in = BufferedReader(InputStreamReader(p.getInputStream())) linenum = 0 Loop forever line = in.readLine if line = null then leave linenum = linenum + 1 rxStdout[linenum] = line End rxStdout['0'] = linenum in = BufferedReader(InputStreamReader(p.getErrorStream())) linenum = 0 Loop forever line = in.readLine if line = null then leave linenum = linenum + 1 rxStderr[linenum] = line End rxStderr['0'] = linenum p.waitFor() rxRc = p.exitValue() p.getInputStream().close() p.getErrorStream().close() p.getOutputStream().close() catch InterruptedException rxStdout['0'] = 0 rxStderr['0'] = 0 rxRc = -9 catch IOException rxStdout['0'] = 0 rxStderr['0'] = 0 rxRc = -9 end return rxRc Best regards Marc Remes IBM Certified IT Specialist IBM Global Technology Services Mobile: 32 475 33 8162 mailto:mremes@...
method Boilerplate(input_data) static signals IOException,InterruptedException; /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /* B O I L E R P L A T E */ /* Identifies program source et c. */ /* */ /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ say "input data were . . . . . " input_data ; parse source Name MethClass Source ; say Name '; ' MethClass '; ' Source ' . . .From parse source in BP , , , '; cmd = 'cmd /c dir "C:\\program files" ' say 'the command is . . . . . ' cmd; r = Runtime.getRuntime() p = r.exec(cmd) class StreamFiler extends Thread is=InputStream filename=String --34567890123456789012345678901234567890123456789 method StreamFiler(is2=InputStream, outputfilename=String) -- constructor method is = is2 method run() public -- a method that runs when the Thread object is started outputfilename='C:\\out_file.txt' -- outputfilename do br = BufferedReader(InputStreamReader(is)) -- create an object to read an output stream outfile = BufferedWriter(FileWriter(outputfilename)) -- create an object to write data to a file line=String null line = br.readLine -- read the first line loop while line \= null -- System.out.println(type ">" line) outfile.write(line,0,line.length) -- write input line to output file outfile.newLine -- advance file to next line line = br.readLine -- read a new input line end outfile.close -- close the file when done catch ioe=IOException -- intercept any io errors and print a trace ioe.printStackTrace() end The code above compiles and runs but does not produce an output file. BobH_______________________________________________ Ibm-netrexx mailing list [hidden email] Tenzij hierboven anders aangegeven: / Sauf indication contraire ci-dessus: / Unless otherwise stated above: International Business Machines of Belgium sprl / bvba Siège social / Maatschappelijke zetel: Avenue du Bourget 42 Bourgetlaan, B-1130 Bruxelles/Brussel N° d'entreprise / Ondernemingsnr: TVA / BTW BE 0405 912 336 RPM Bruxelles / RPR Brussel _______________________________________________ Ibm-netrexx mailing list [hidden email] smime.p7s (12K) Download Attachment |
On 10 November 2010 12:53, Marc Remes <[hidden email]> wrote: While an interesting exercise in itself, I fail to see why you take a system neutral environment like the JVM and make it system dependent by using operating system commands. The whole point of the Java world is to make programs "write once, debug everywhere" not "write for this platform, then rewrite for the next platform, then..."Runtime.getRuntime().exec needs an array. The java.io.File class provides a perfectly system independent way of listing the contents of a directory (http://download.oracle.com/javase/1.5.0/docs/api/java/io/File.html#list%28%29) that does the job without jumping through hoops and creating a separate runtime environment. e.g: fn = File('C:/Program Files') ff = fn.list() loop ix = 0 to ff.length - 1 say ff[ix] end ix The same class also provides all kinds of information about File objects, like file type, size, attributes etc. If you're looking for an alternative to Windows Batch then Java based languages are a very bad choice: horses for courses... Alan. -- Can't tweet, won't tweet! _______________________________________________ Ibm-netrexx mailing list [hidden email]
Alan
-- Needs more cowbell. |
On 11/10/2010 4:28 PM, Alan Sampson wrote:
This code also requires a preliminary "import java.io.File" ... but otherwise serves as an excellent example. Tom. _______________________________________________ Ibm-netrexx mailing list [hidden email] |
On 10 November 2010 15:01, Tom Maynard <[hidden email]> wrote: Really? Didn't for me...
A. -- Can't tweet, won't tweet! _______________________________________________ Ibm-netrexx mailing list [hidden email]
Alan
-- Needs more cowbell. |
In reply to this post by Robert L Hamilton
Bob ;
That code does not look quite like what you shared before. Did you accidentally omit the part that calls your method? As René pointed out, there is not much point in defining classes and methods if no code accesses them. NetRexx will create a basic class and "main" method so Java can start your program but you have to do the rest. Your method is also missing the code that creates the stream handler threads and starts them. Below is a modified version of your code that will work. (Note - using "source"for both input and output variable in parse seems to break the NetRexx interpreter.) The system command you execute may write to both the standard output and the error output streams in general. If either one fills it's output buffer, the whole command will hang. That is why you need separate threads to read each stream. As Alan pointed out, although this code is valid for issuing system commands in general, using it this way to issue a "dir" command limits your program to only run on Windows systems. There are Java class library methods that are easier to use for getting directory and file information and they work on Unix or Mac systems as well as Windows systems. -- Kermit ----------------------------------------------------------------------------------------------------------------------------------- Boilerplate(arg) method Boilerplate(input_data) static signals IOException,InterruptedException; /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /* B O I L E R P L A T E */ /* Identifies program source et c. */ /* */ /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ say "input data were . . . . . " input_data ; parse source Name MethClass fileSource say Name '; ' MethClass '; ' fileSource ' . . .From parse source in BP , , , '; cmd = 'cmd /c dir "C:\\program files" ' say 'the command is . . . . . ' cmd; r = Runtime.getRuntime() p = r.exec(cmd) errorGobbler = StreamGobbler(p.getErrorStream(), "ERROR") -- any error message? outputFiler = StreamFiler(p.getInputStream(), 'filename-is-ignored-now') -- any output? errorGobbler.start() -- kick them off outputFiler.start() class StreamFiler extends Thread is=InputStream filename=String method StreamFiler(is2=InputStream, outputfilename=String) -- constructor method is = is2 method run() public -- a method that runs when the Thread object is started outputfilename='C:\\out_file.txt' -- outputfilename do br = BufferedReader(InputStreamReader(is)) -- create an object to read an output stream outfile = BufferedWriter(FileWriter(outputfilename)) -- create an object to write data to a file line=String null line = br.readLine -- read the first line loop while line \= null -- System.out.println(type ">" line) outfile.write(line,0,line.length) -- write input line to output file outfile.newLine -- advance file to next line line = br.readLine -- read a new input line end outfile.close -- close the file when done catch ioe=IOException -- intercept any io errors and print a trace ioe.printStackTrace() end class StreamGobbler extends Thread is=InputStream type=String method StreamGobbler(is2=InputStream, type2=String) is = is2 type = type2 method run() public do br = BufferedReader(InputStreamReader(is)) line=String null line = br.readLine loop while line \= null System.out.println(type ">" line) line = br.readLine end catch ioe=IOException ioe.printStackTrace() end ----------------------------------------------------------------------------------------------------------------------------------- On 11/10/2010 11:11 AM, Robert Hamilton wrote: method Boilerplate(input_data) static signals IOException,InterruptedException; _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by Tom Maynard
Works on DELL laptop Windoze XP SP3
bobh On Wed, Nov 10, 2010 at 5:01 PM, Tom Maynard <[hidden email]> wrote:
_______________________________________________ Ibm-netrexx mailing list [hidden email] |
On 11/11/2010 11:14 AM, Robert Hamilton wrote:
Works on DELL laptop Windoze XP SP3I withdraw my earlier proviso. The code compiles and runs just fine exactly as in the original post. I must have been hallucinating. (It happens.) Tom _______________________________________________ Ibm-netrexx mailing list [hidden email] |
Hello Tom Maynard:
Relating Halluniciaton: Do you know, what exacltly will happen on the 21.12.2012 ?? *NOT* the end of our living. *NOT* the Apokalypse. What is (will be) really happening on this day is: Our well beloved SUN is appreaching the *middle* of our *local Universe*, exactly on this day. Therefore, our SUN will produce a LOT of protuberances. This will, in fact, influence life on this earth very dramatically: 1.) We will see so called POLAR-LIGHT (usually only in the SUMMER in FINLAND and SWEDEN) *all araound of the Earth) 2.) Most probably, on *our Earth*, we will have one day where all: a) Handy's won't work b) GPS Systems won't work c) Satellite Systems won't work 3.) Thus, we would simply see out Earth surrounded by POLAR Lights. Very fascinating, you will see. 4.) The old Mayas, as you do (hopefully) know, did predict this Day in their calendar as day Number 13.0.0.0.0 5.) Actually, the SUN is in this position (in the middle of the milky-way) only all 26.000 years (exactly speaking, only all 25.800 years quoting the current rotation time of the (our) earth ... Now, my question, dear *informatic people* 6.) Wherefrom did the Mayas in their famous calender get this knowledge from ??? Thomas Schneider. ============================================================= Niverse a Am 11.11.2010 19:53, schrieb Tom Maynard: On 11/11/2010 11:14 AM, Robert Hamilton wrote:Works on DELL laptop Windoze XP SP3I withdraw my earlier proviso. The code compiles and runs just fine exactly as in the original post. I must have been hallucinating. (It happens.) --
Thomas Schneider Projects ReyC & LOGOS on www.KENAI.com _______________________________________________ Ibm-netrexx mailing list [hidden email]
Tom. (ths@db-123.com)
|
Hi Tom,
that is fascinating to know. I hope the Mayas had some rope with knots that encoded some early form of Rexx and did not bother with curly braces in any way. But may we try to stay on-topic? best regards, René On Fri, Nov 12, 2010 at 4:44 PM, Thomas Schneider <[hidden email]> wrote: > Hello Tom Maynard: > > Relating Halluniciaton: > > Do you know, what exacltly will happen on the 21.12.2012 ?? > > *NOT* the end of our living. > *NOT* the Apokalypse. > > What is (will be) really happening on this day is: > > Our well beloved SUN is appreaching the *middle* of our *local Universe*, > exactly on this day. > > Therefore, our SUN will produce a LOT of protuberances. > > This will, in fact, influence life on this earth very dramatically: > > 1.) We will see so called POLAR-LIGHT (usually only in the SUMMER in FINLAND > and SWEDEN) *all araound of the Earth) > > 2.) Most probably, on *our Earth*, we will have one day where all: > > a) Handy's won't work > b) GPS Systems won't work > c) Satellite Systems won't work > > 3.) Thus, we would simply see out Earth surrounded by POLAR Lights. > Very fascinating, you will see. > > 4.) The old Mayas, as you do (hopefully) know, did predict this Day in their > calendar as day Number 13.0.0.0.0 > > 5.) Actually, the SUN is in this position (in the middle of the milky-way) > only all > 26.000 years (exactly speaking, only all 25.800 years quoting the current > rotation time of the (our) earth ... > > Now, my question, dear *informatic people* > > 6.) Wherefrom did the Mayas in their famous calender get this knowledge from > ??? > > Thomas Schneider. > ============================================================= > > Niverse > a > Am 11.11.2010 19:53, schrieb Tom Maynard: > > On 11/11/2010 11:14 AM, Robert Hamilton wrote: > > Works on DELL laptop Windoze XP SP3 > > I withdraw my earlier proviso. The code compiles and runs just fine exactly > as in the original post. I must have been hallucinating. (It happens.) > > Tom > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > > > > -- > Thomas Schneider Projects ReyC & LOGOS on www.KENAI.com > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > > > _______________________________________________ Ibm-netrexx mailing list [hidden email] |
On 12 November 2010 08:07, René Jansen <[hidden email]> wrote: Hi Tom, Rope? Knots? Now I'm interested... Do they work in the JVM? Do tell... A. -- Can't tweet, won't tweet! _______________________________________________ Ibm-netrexx mailing list [hidden email]
Alan
-- Needs more cowbell. |
Hi Alan, *and all* :
1.) Do *not* know, whether the Mayas did have Rexx :-( 2.) They *must have had*, as thery did have an 11, 12, *and* 13 arithmetic (at the same time) :-) :-) :-) 3.) they therefore have been able to calculate soooo many things, for instance, *The Day* 13.0.0.0 0 (Maya Notation) -- which is -- *By instance*, *by default*, **or** by *eternity: The 21.12.2012 (Austrian Notation), which is denoted 21/12/2012 *or* 12/21/2012 -- guess why :-) :-) :-) -- and guess where :-) :-) :-) So What ! Isn't it time ?? For what ? Thomas Schneider. ============================================================= Am 12.11.2010 17:47, schrieb Alan Sampson:
--
Thomas Schneider Projects ReyC & LOGOS on www.KENAI.com _______________________________________________ Ibm-netrexx mailing list [hidden email]
Tom. (ths@db-123.com)
|
In reply to this post by alansam
Hi Alan
I'm working as you: *by brain* *using my fingers* Thomas Schneider. ============================================================== Am 12.11.2010 17:47, schrieb Alan Sampson:
--
Thomas Schneider Projects ReyC & LOGOS on www.KENAI.com _______________________________________________ Ibm-netrexx mailing list [hidden email]
Tom. (ths@db-123.com)
|
In reply to this post by Thomas.Schneider.Wien
On Fri, Nov 12, 2010 at 12:44 PM, Thomas Schneider <[hidden email]> wrote:
> Our well beloved SUN is appreaching the *middle* of our *local Universe*, > exactly on this day. The only SUN I worshipped was *SUN* Microsystems. Sadly the *Sun* is gone, but luckily I can see on the *ORACLE* that a lot of its *STARS* will continue SHINING ON, thanks to open source (ie OpenJDK, Netbeans,Glassfish, Virtualbox, etc ). With kind regards, FC _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by alansam
Wasn't it Incas that used knots?
On Fri, Nov 12, 2010 at 11:47 AM, Alan Sampson <[hidden email]> wrote:
_______________________________________________ Ibm-netrexx mailing list [hidden email] |
Ancient mariners, I thought :-) -- Can't tweet, won't tweet! _______________________________________________ Ibm-netrexx mailing list [hidden email]
Alan
-- Needs more cowbell. |
In reply to this post by George Hovey-2
Both Inca's and Mayas did use knot's to count things:
1,2,3,4,5,6,7,8,9 Interestingly, the Mayas had their own notation for mathmatics: 'I' did mean FIVE 'II' did mean TEN 'III' did mean FIFTEEN ... and 'IIII' did mean TWENTY. Hence, they did simply denote *one hand* by a *I*. *two hands* by a *II* They didn't have a DECIMAL *based* system therefore, but a system based on FIVE, and differences/additions to five, denoted by *dots* DOT. DOT DOT, DOT DOT DOT, DOT DOT DOT, *FIVE* The *DOTS* have been written vertically, interestingly. Probably to +save space+ ... Thomas Schneider. . =============================================================== Am 12.11.2010 19:20, schrieb George Hovey: Wasn't it Incas that used knots? --
Thomas Schneider Projects ReyC & LOGOS on www.KENAI.com _______________________________________________ Ibm-netrexx mailing list [hidden email]
Tom. (ths@db-123.com)
|
In reply to this post by George Hovey-2
Hello George again,
2 question: 1.) what *is the difference* between a *D*OT and a *KN*OT 2.) *and* , what they do have common ? HINT: Do read them from right to left :-) :-) :-) Thomas. ============================================================= Am 12.11.2010 19:20, schrieb George Hovey: Wasn't it Incas that used knots? --
Thomas Schneider Projects ReyC & LOGOS on www.KENAI.com _______________________________________________ Ibm-netrexx mailing list [hidden email]
Tom. (ths@db-123.com)
|
In reply to this post by Thomas.Schneider.Wien
I will need your help, please.
I am sending you a message in varios languages: ... --- ... :I ::=:: II ::: :-) :-) :-) Dai mi busho, moi milacik, jeden, dwa, tri, djakujem, doswidania Dai mi bushi, moi kochanie, rast, dwa, dzi, dcickuja, dowicenia. Give me a kiss, my darling, one, two, three, bye, bye Gib mir ein Bussi, mein Liebling, eins, zwei, drei; Auf WiederSchaun! ========================================================== Capisci ??? =============================================== Am 12.11.2010 19:37, schrieb Thomas Schneider: Both Inca's and Mayas did use knot's to count things: --
Thomas Schneider Projects ReyC & LOGOS on www.KENAI.com _______________________________________________ Ibm-netrexx mailing list [hidden email]
Tom. (ths@db-123.com)
|
Free forum by Nabble | Edit this page |