Hi,
I am trying to run a linux commands from a
java app.The below code works for executing windows commands in java application,but how can i do in Linux. Please help me it very urgent.
Thanks,
try
{
String osName = System.getProperty("os.name" );
System.out.println(" OS NAME is "+osName);
// String[] cmd = new String[3];
if( osName.equals( "Windows 2000" ) )
{
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2] = args;
}
Runtime rt = Runtime.getRuntime();
System.out.println("Execing " + cmd[0] + " " + cmd[1]
+ " " + cmd[2]);
Process proc = rt.exec();
// any error message?