runtime.exec - Java - Command Execution in Runtime -


i tried out simple program execute linux command @ run time. following program gets compiled , runs without error, text file not getting created intended.is there wrong in program?

import java.io.*; class executejava {     public static void main(string args[])     {             string historycmd = "cat ~/.bash_history >> documents/history.txt";             try             {                     runtime runtime = runtime.getruntime();                     process proc = runtime.exec(historycmd);             }             catch(exception e)             {                     system.out.println(e);             }     } } 

the append operator >> meant interpreted part of command shell. use

string[] historycmd =             { "bash", "-c", "cat ~/.bash_history >> documents/history.txt"}; 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -