My program runs on ubuntu 10.04, and here is the code:
Process process=Runtime.getRuntime().exec("ls",null,null);
it throws an exception:
Cannot run program "ls": java.io.IOException: error=2, No such file or directory,
and I tried changing "ls" to "chmod", "pwd", I did not find any shell commands, everything came to the same problem (I also tried "/ bin / sh -c ls")
and then I change the code to:
Process process=Runtime.getRuntime().exec("/bin/ls",null,null);
it throws an exception:
Cannot run program "/bin/ls": java.io.IOException: error=13, Permission denied
I changed the privilege of all related files and directories to 777, so I really don't know what is wrong with it.
Thank you for your responses.
source
share