Re: Receiving the output of CommandInterpreter.execute command from Slush
"Kris Ardis" <Kristopher.Ardis-6tN4nzCoH/[email protected]> Mon, 28 Jun 2004 07:47:42 -0500
| Newsgroups | gmane.comp.hardware.microcontrollers.tini |
|---|---|
| Message-ID | <003901c45d0e$1a2f4f90$764000b4@kardis> |
I don't think what you have here will work, the streams you pass to Slush's command interpreter are meant for that command's use, so the output of the command will be spit out the 'out' output stream, it won't be available from standard in. You might be able to do what you are trying by creating a new SystemPrintStream around a ByteArrayOutputStream, run the command, then get the output from your ByteArrayOutputStream. Note that it may be more efficient for you to do whatever processing you need to do by taking the source of PSCommand from Slush and stealing the relevant portions for your app. What you are doing here is going to create lots of strings, which can lower your performance. Kris ----- Original Message ----- From: "Mihaela Tarjoianu" <mihaela_tarjoianu-/[email protected]> To: "Tini List" <tini-6tN4nzCoH/[email protected]> Sent: Friday, June 18, 2004 3:14 AM Subject: [TINI]Receiving the output of CommandInterpreter.execute command from Slush > Hello, > > I am trying to execute commands in Slush and I'm > interested to receive the results. > So I'm using the following code, but I don't > receive anything. What can be wrong? Don't I use > properly the streams? Or should I make some settings > first? I'm using tini1.12. > Many thanks! > > > SystemPrintStream out = (SystemPrintStream)System.out; > SystemInputStream in = (SystemInputStream)System.in; > > try{ > CommandInterpreter.execute(Session.getParams("ps"), > in, out,out, TINIOS.getCurrentEnvironment()); > }catch(Exception e){ > parentSlush.broadcast("Error: "+e); > } > > // waiting 30 seconds > try{Thread.sleep(30000);}catch(InterruptedException > ie){} > > // reading only nrBytes from the answer to the command > > byte[] buffer; > try{ > int nr=in.available(); > > if (nr>nrBytes) > nr=nrBytes; > buffer=new byte[nr]; > in.read(buffer, 0, nr); > > parentSlush.broadcast("result: "+new > String(buffer)); > > }catch(Exception e){ > parentSlush.broadcast("Error: "+e); > } > > > > > __________________________________ > Do you Yahoo!? > Yahoo! Mail is new and improved - Check it out! > http://promotions.yahoo.com/new_mail > _______________________________________________ > TINI mailing list > TINI-6tN4nzCoH/[email protected] > To UNSUBSCRIBE, edit your profile, or see list archives: > http://lists.dalsemi.com/mailman/listinfo/tini > _______________________________________________ TINI mailing list TINI-6tN4nzCoH/[email protected] To UNSUBSCRIBE, edit your profile, or see list archives: http://lists.dalsemi.com/mailman/listinfo/tini