Rune911 0 Newbie Poster

I'm trying to use Java to echo a command to another shell, but I have had no luck doing so so far.

echo xcommand | /usr/bin/tshell

In the linux shell this is processed as echo xcommand to the tshell shell and works properly. In java all it does is echo "xcommand | /usr/bin/tshell" like this:

~ # java showtacvideo
xcommand | /usr/bin/tshell

If anything isn't clear enough, please let me know.

Also, I did not write half this code, I'm just tinkering with it for learning purposes for now.

public static void main(String args[]) {
	        try {      
	            Process p = Runtime.getRuntime().exec("echo xcommand | /usr/bin/tshell");
	            PrintStream out = new PrintStream(p.getOutputStream());
	            BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
	            while (in.ready()) {   
	            	String s = in.readLine();
	            	System.out.println(s); }
	            
	            System.exit(0);
	        }
	        catch (Exception e) {
	            System.out.println("exception happened - here's what I know: ");
	            e.printStackTrace();
	            System.exit(-1);
	        }
	    }

Thanks for reading this to the end!
And a pre-emptive thanks for anyone who helps.