Skip to content

Instantly share code, notes, and snippets.

@sujee
Created August 25, 2011 00:00
Show Gist options
  • Save sujee/1169615 to your computer and use it in GitHub Desktop.
Save sujee/1169615 to your computer and use it in GitHub Desktop.
hadoop utilities : Shell
import org.apache.hadoop.util.Shell.ShellCommandExecutor;
String[] cmd = { "ls", "/usr" };
ShellCommandExecutor shell = new ShellCommandExecutor(cmd);
shell.execute();
System.out.println("* shell exit code : " + shell.getExitCode());
System.out.println("* shell output: \n" + shell.getOutput());
/* output:
* shell exit code : 0
* shell output:
X11
X11R6
bin
etc
include
lib
libexec
llvm-gcc-4.2
local
sbin
share
standalone
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment