I have a sh file which conatins a many sudo commands, say a script as below:
test.sh
#!/bin/sh
sudo apt-get install gedit
sudo date --set="2014/02/20 10:00"
When I execute the test.sh from terminal it works fine. Problem is when I try to execute this file from a java class. The script doesn't execute. I tried this:
Process proc = Runtime.getRuntime().exec("/bin/sh","/home/priyatam/test.sh");
Does anyone have an idea to execute this sudo command from java class? Please share.