Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-31-2007, 04:51 PM
Member
 
Join Date: Dec 2007
Posts: 1
abhishek.sinha is on a distinguished road
Accessing unix system using java
I am trying to access a unix system using java .

Main idea is to run the command in unix shell and get the output and display in a window created in java
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-23-2008, 08:23 AM
dowell's Avatar
Member
 
Join Date: May 2008
Posts: 6
dowell is on a distinguished road
Is the application running from windows or from unix???
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-23-2008, 02:57 PM
danielstoner's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Canada
Posts: 183
danielstoner is on a distinguished road
It is really not clear what you are trying to do. Just run a Java application on UNIX? Do you try to run a Java application from a Telnet session? Explain better.
__________________
Daniel @ [
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
]
Language is froth on the surface of thought
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-19-2008, 09:05 AM
serjant's Avatar
Member
 
Join Date: Jun 2008
Location: Israel,Tel-Aviv
Posts: 40
serjant is on a distinguished road
Send a message via ICQ to serjant Send a message via Skype™ to serjant
Here the output of two commands are shown in JTextArea

Code:
import java.util.*; import java.io.*; import javax.swing.*; public class Shell { private static String command = "ls -Als"; private static String command2 = "cat /etc/profile"; private String string=""; public static void main(String[] args) throws java.io.IOException { JFrame frame=new JFrame("Output"); JTextArea textArea=new JTextArea(); textArea.setEditable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.getContentPane().add(textArea); frame.setSize(500,800); frame.setVisible(true); try { Process child = Runtime.getRuntime().exec(command); // Get the input stream and read from it InputStream in = child.getInputStream(); int c; while ((c = in.read()) != -1) { textArea.append(String.valueOf((char)c)); } in.close(); } catch (IOException e) { } try { Process child = Runtime.getRuntime().exec(command2); // Get the input stream and read from it InputStream in = child.getInputStream(); int c; while ((c = in.read()) != -1) { textArea.append(String.valueOf((char)c)); } in.close(); } catch (IOException e) { } } }

Last edited by serjant : 06-19-2008 at 09:15 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
accessing command prompt using java (netbeans)... kureikougaiji New To Java 6 06-27-2008 04:01 PM
how to run java app on windows in a cron like on unix rockie12 Advanced Java 7 05-23-2008 02:39 PM
Filter a file in java (unix cut command equivalent) marcosabel New To Java 0 02-11-2008 08:26 PM
Running java program with arguments in Unix" gvi Advanced Java 2 11-08-2007 08:01 PM
Accessing client file system revathi17 New To Java 1 10-17-2007 11:17 AM


All times are GMT +3. The time now is 12:05 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org