There isn't any problem using ProcessBuilder in NetRexx 3.0.2, but how do I use a LinkedList ?
For example, how does the following get converted in NetRexx: List<String> cmd = new LinkedList<String>(); cmd.add("java"); cmd.add("-version"); Compilation returns: 1 +++ List<String> cmd = LinkedList<String>() +++ ^^^^ +++ Error: Keyword symbol expected And: 1 +++ cmd = LinkedList<String>() +++ ^ +++ Error: Left-hand operand cannot be just a type 'java.util.LinkedList' |
l = LinkedList()
l.add('java') l.add('-version') will work. In this case, we are using Rexx strings, which is fine for Processbuilder. We cannot constrain the elements of the linked list to string as the Java call does, because that support is not there yet; imho, it is not really needed. In my OSProcess class I have a helper method that does: /* * helper method that makes an ArrayList of out a Rexx string for use * in the similarly named method that has an ArrayList as input */ method exec(command_=Rexx, wait=1) if command_ = '', command_ = null then return a = ArrayList() loop until command_ = '' parse command_ first command_ a.add(first.toString()) end this.exec(a,wait) so you can specify the command on one line, which is how I prefer to do it. René. On 15 jul. 2013, at 14:48, gpatrick <[hidden email]> wrote: > There isn't any problem using ProcessBuilder in NetRexx 3.0.2, but how do I > use a LinkedList ? > > For example, how does the following get converted in NetRexx: > List<String> cmd = new LinkedList<String>(); > cmd.add("java"); > cmd.add("-version"); > > Compilation returns: > 1 +++ List<String> cmd = LinkedList<String>() > +++ ^^^^ > +++ Error: Keyword symbol expected > > And: > 1 +++ cmd = LinkedList<String>() > +++ ^ > +++ Error: Left-hand operand cannot be just a type 'java.util.LinkedList' > > > > -- > View this message in context: http://ibm-netrexx.215625.n3.nabble.com/Can-NetRexx-do-LinkedList-tp4026693.html > Sent from the ibm-netrexx mailing list archive at Nabble.com. > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ > _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
... and don't forget to redirect the error stream. This works standalone:
l = LinkedList() l.add('java') l.add('-version') pb = ProcessBuilder(l) pb.redirectErrorStream(1) pid = pb.start() in = BufferedReader(InputStreamReader(pid.getInputStream())) line = Rexx in.readLine() loop while line <> null say line line = Rexx in.readLine() end best regards, René. On 15 jul. 2013, at 15:09, René Jansen <[hidden email]> wrote: l = LinkedList() _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Free forum by Nabble | Edit this page |