vendredi 20 février 2015

Piping commands in Java



I know there are a lot of links on this topic but none of them exactly answered my problem.


From my Java program I need to exec the following command:



sudo nohup hcidump --raw|myProgram arg1 arg2


My approach:



String[] cmd = {"/bin/sh", "-c", "sudo nohup hcidump --raw | myProgram arg1 arg2"};
Process p = Runtime.getRuntime().exec(cmd);


However, I get a usage error for sudo.


Any suggestions on how I can pipe this?




Aucun commentaire:

Enregistrer un commentaire