Run a filesystem command. Any output from this command is written to stdout or stderr as appropriate. @param cmd Filesystem command to run along with its arguments as one string. @throws IOException
(String cmd)
| 55 | * @throws IOException |
| 56 | */ |
| 57 | public static int fs(String cmd) throws IOException { |
| 58 | ScriptPigContext ctx = getScriptContext(); |
| 59 | FsShell shell = new FsShell(ConfigurationUtil.toConfiguration(ctx |
| 60 | .getPigContext().getProperties())); |
| 61 | int code = -1; |
| 62 | if (cmd != null) { |
| 63 | String[] cmdTokens = cmd.split("\\s+"); |
| 64 | if (!cmdTokens[0].startsWith("-")) cmdTokens[0] = "-" + cmdTokens[0]; |
| 65 | try { |
| 66 | code = shell.run(cmdTokens); |
| 67 | } catch (Exception e) { |
| 68 | throw new IOException("Run filesystem command failed", e); |
| 69 | } |
| 70 | } |
| 71 | return code; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Run a sql command. Any output from this command is written to |
no test coverage detected