This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to run unix command using Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to run unix command using Java" Watch "How to run unix command using Java" New topic
Author

How to run unix command using Java

Manohar Chhapolia
Greenhorn

Joined: Nov 22, 2006
Posts: 17
Hi all,

I have two queries regarding execution of java program on Solaris.

1. Can we run UNIX command using Java and get the output back to Java for the further analysis?
2. Can we run it from one JVM (first UNIX machine) to another JVM (second UNIX machine)? (Actually, I want to run same script on many Solaris and get the out for further analysis)

Thanks and Regards,
Manohar
Chris Hurst
Ranch Hand

Joined: Oct 26, 2003
Posts: 396

The answer to 1. is yes and google java class ProcessBuilder similarly google for some examples you'll find a lot of them on the net and they work fine with Solaris though user accounts and shells can be fun ;-)


"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

And always remember to read the javaworld article "Why Runtime.exec() doesn't"


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to run unix command using Java
 
Similar Threads
JVM initializatin error
Serial Port Ethernet
C++
writing to a file on remote solaris machine
Loadjava program