A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
How to execute a command from Java in Linux?
Joined: May 17, 2004
Jun 15, 2007 23:40:00
I am trying to execute a command from Java in linux, like this:
cmd = ..... ;
Process x = Runtime.getRuntime().exec( cmd );
But my problem is I need to setup some shell variables for my Linux command?
How can I do that?
And I am running this Runtime.getRuntime().exec() in my own
Thank you for any tips.
Joined: Mar 22, 2005
Jun 16, 2007 01:10:00
You can run the command inside of a short shell script, which would set up the shell variables, and then call the actual command.
Ping & DNS, my free Android app for network diagnostics
It is sorta covered in the
JavaRanch Style Guide
subject: How to execute a command from Java in Linux?
Runtime getRuntime() exec(String command) - How does this work?
Mysql database restore through java application...?
Running a .bat/ .cmd file from Java
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014