I tried:
final ProcessBuilder pb = new ProcessBuilder("umount", "foldername");
final Process p = pb.start();
Throws
umount: /home/user/foldername is not in the fstab (and you are not
root)
I tried
final ProcessBuilder pb = new ProcessBuilder("sudo","umount", "foldername");
final Process p = pb.start();
Throws
sudo: sorry, you must have a tty to run sudo
I got the root password, but can’t provide it to the ProcessBuilder. Also I cannot edit fstab (or whatever is needed to be edited), because it is remote virutal machine started on a remote server from saved OS image.
I just want to run the command as root.
You have a couple of options:
Make the controlling terminal available for
sudoso that the user can type the password there.Execute the program with
gksudorather thansudo. Systems that use GTK+ often come with thegksupackage as a graphical interface forsuandsudo.Open a terminal emulator window for
sudo: