+ List<String> commandsToUse = new ArrayList<String>(commands);
+ String commandToUse = command;
+ // convert system calls
+ if (systemCall != null) {
+ if (command != null)
+ throw new SlcException("Cannot specify command AND systemCall");
+ commandToUse = convertSystemCall(systemCall);
+ }
+
+ if (systemCalls.size() != 0) {
+ if (commandsToUse.size() != 0)
+ throw new SlcException(
+ "Cannot specify commands AND systemCalls");
+ for (SystemCall systemCall : systemCalls)
+ commandsToUse.add(convertSystemCall(systemCall));
+ }
+
+ if (script != null) {
+ if (commandsToUse.size() != 0)
+ throw new SlcException("Cannot specify commands and script");
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(script
+ .getInputStream()));
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ if (!StringUtils.hasText(line))
+ continue;
+ commandsToUse.add(line);
+ }
+ } catch (IOException e) {
+ throw new SlcException("Cannot read script " + script, e);
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ }
+
+ if (forceShell) {
+ commandsToUse.add(commandToUse);
+ commandToUse = null;
+ }
+
+ // execute command(s)
+ if (commandToUse != null) {
+ if (commandsToUse.size() != 0)