I need to run a command at terminal in Fedora 16 from a JAVA program. I tried using
Runtime.getRuntime().exec("xterm"); but this just opens the terminal, i am unable to execute any command.
I also tried this:
OutputStream out = null; Process proc = new ProcessBuilder("xterm").start(); out = proc.getOutputStream(); out.write("any command".getBytes()); out.flush(); but still i can only open the terminal, but can't run the command. Any ideas as to how to do it?
Runtime.getRuntime().exec(<insert command name here>);You dont need to openxtermthat is what is opening your terminal.sh -s, and you can use the code you wrote, the shell will accept the commands from the stream, orsh -c <the command you want to run>, and the command specified in the argument will be run.