BrightSide Workbench Full Report + Source Code
org.turro.elephant.impl.util.ShellExecutor Class Reference

Classes

class  StreamExecutor
 

Public Member Functions

 ShellExecutor ()
 
int execute (String command)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 32 of file ShellExecutor.java.

Constructor & Destructor Documentation

◆ ShellExecutor()

org.turro.elephant.impl.util.ShellExecutor.ShellExecutor ( )

Definition at line 59 of file ShellExecutor.java.

59  {
60  }

Member Function Documentation

◆ execute()

int org.turro.elephant.impl.util.ShellExecutor.execute ( String  command)

Definition at line 62 of file ShellExecutor.java.

62  {
63 
64  try {
65  String cmd[] = new String[3];
66 
67  cmd[0] = "sh";
68  cmd[1] = "-c";
69  cmd[2] = command;
70 
71  Runtime rt = Runtime.getRuntime();
72  Logger.getLogger(ShellExecutor.class.getName()).log(Level.INFO, "Executor: " + command);
73 
74  Process proc = rt.exec(cmd);
75 
76  StreamExecutor errorStream = new StreamExecutor(proc.getErrorStream(), Level.SEVERE);
77 
78  StreamExecutor outputStream = new StreamExecutor(proc.getInputStream(), Level.INFO);
79 
80  errorStream.start();
81  outputStream.start();
82 
83  int exitVal = proc.waitFor();
84 
85  Logger.getLogger(ShellExecutor.class.getName()).log(Level.INFO, "Executor exit value for " + command + ": " + exitVal);
86 
87  return exitVal;
88 
89  } catch (Throwable t) {
90  Logger.getLogger(ShellExecutor.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), t);
91  }
92 
93  return -1;
94  }
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: