This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes unix commands thru java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "unix commands thru java program" Watch "unix commands thru java program" New topic
Author

unix commands thru java program

Bhasker Reddy
Ranch Hand

Joined: Jun 13, 2000
Posts: 176
can we issue unix commands thru java program.
I am writing a java file, i have shell program. I need to
issue those directives to the unix system thru java program
can i do that.
does anyone has any idea regarding this.
if i am not clear enough please let me know
thanks


Bhasker Reddy
Kripal Singh
Ranch Hand

Joined: Jul 26, 2001
Posts: 254
you can execute your command using following code
Runtime rt = Runtime.getRuntime();
try{
Process ps = rt.exec(your command here);

}
catch(Exception e)
{
System.out.print(e.getMessage());
}


# Help an unprivileged kid.<br /> Whatever u do will make a difference...<br /> ...to a child's life & ur own #<br /><a href="http://www.cry.org/" target="_blank" rel="nofollow">www.cry.org/</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unix commands thru java program
 
Similar Threads
can I run telnet thru a java program?
I want to login ( using Telnet ) to a Unix server
Issue commands from Java
issuing unix commands thru java program
I wanted to login ( using Telnet ) to a Linux server