• Post Reply Bookmark Topic Watch Topic
  • New Topic

Display UNIX Commands in TextArea  RSS feed

 
Mike Cutter
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you capture UNIX commands that produce only output into a TextArea? Say, I want to display the results of the UNIX "df" or "who" command into the TextArea. I know that I would have to somehow take the results and input it into a Stream, convert the Stream into a String, and display the String in the TextArea.

I know how to take a file like /etc/passwd and display it into a TextArea. I want to try and avoid the step of piping the results of the UNIX command into a file and then capturing the file into the TextArea.

If someone could provide me a snippet of Java code to capture the results of the UNIX command into a String, I would be on my way.

Thanks,

Mike
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37255
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike,
If you take a look at Runtime.exec(), you can get the output in a stream. Then copy it from the stream to the text area.
 
Jeffrey Spaulding
Ranch Hand
Posts: 149
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!