String[] cmd = {"/bash/bin","-c"," echo password| sudo -S rm -rf /home/ftp"};
Process p = Runtime.getRuntime.exec(cmd);
Provide input for the process using the pipe. Running echowith a space will remove it from the bash history.
You can also delete the story later:
new File(System.getProperty("user.home"), ".bash_history").delete();
but be careful with him. There is a trick to delete only the latest entries.
source
share