getRuntime().exec("chmod 777 a file.txt") - does not do the intended task
843798Feb 16 2005 — edited Feb 16 2005Hi,
I am trying to change the permissions of file (file name has spaces) using the Runtime.getRuntime().exec() method on AIX platform. My sample code is -
import java.io.*;
public class ChangeMode
{
public static void main(String[] args)
{
Process p = null;
String cmd = null;
cmd = "chmod " + "000" + " " + "a file.txt";
try
{
p = Runtime.getRuntime().exec( cmd );
p.waitFor();
}
catch( Exception e )
{
e.printStackTrace();
}
System.out.println("The exit value "+p.exitValue());
}
}
In this case - I am getting exitValue of 2.
But, the strange part is that - I am able to run the command
"chmod 000 a file.txt "
from the command prompt successfully.
Any ideas what does an exitValue of 2 means and where is this program getting failed.
Thanks!
~Saurabh