[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

displaying UNIX stdout in JAVA GUI

Posted on 2002-06-24
4
Medium Priority
?
326 Views
Last Modified: 2012-05-04
I have a a simple GUI with
1. TEXT AREA
2. BUTTON

when I push the button, the program runs a simple UNIX command (for example, "who" or "ls")
I need to echo the results of that command to the text area.

I don't want to do this by redirection to a file ("ls > outputfile") and then opening the file for the textarea.

I want to do this in real time, if possible (For example, if the unix command is a long "grep", then the results would scroll on the text area.

is this possible to do???

By the way, I am using JAVA NATIVE to run the unix commands ('C' system call)
0
Comment
Question by:happyloman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 600 total points
ID: 7104564
Careful - you've posted this several times!

import java.io.*;
public class Exec {
  public Exec(String cmdline) {
    try {
     String line;
     Process p = Runtime.getRuntime().exec(cmdline);
     BufferedReader input =
       new BufferedReader
         (new InputStreamReader(p.getInputStream()));
     while ((line = input.readLine()) != null) {
       System.out.println(line);
       // append to your TextArea here
       }
     input.close();
     }
    catch (Exception err) {
     err.printStackTrace();
     }
   }

public static void main(String argv[]) {
  new Exec("ls -l");
  }
}
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7104794
Duplicate Question Experts please post comments here:
http://www.experts-exchange.com/java/Q_20315518.html

Happyloman: Please delete this question.

Thanx,
CJ
0
 
LVL 9

Expert Comment

by:Ovi
ID: 7106677
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7109289
You posted this same question 11 times, and all have been closed.  Those which contained help to you we can leave, but others which were experts trying to alert you of the multiple entries, I'll refund for you.  Please use the "reload" button versus your Browser control buttons, and also don't hit submit more than once when creating a question.  

If you need help, any time, post a zero point question here:
http://www.experts-exchange.com/commspt/
Include the question link (URL)

Thank you,
Moondancer - EE Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question