public void runLocalCommand ( String command ) throws Exception { String result = "" ; String line ; Process p ; try { p = Runtime . getRuntime ( ) . exec ( new String [ ] { "/bin/sh" , "-c" , command } ) ; p . waitFor ( ) ; } catch ( java . io . IOException e ) { this . commandExitStatus = 1 ; this . commandResult = "Error" ; return ; } BufferedReader input = new BufferedReader ( new InputStreamReader ( p . getInputStream ( ) ) ) ; while ( ( line = input . readLine ( ) ) != null ) { result += line ; } input . close ( ) ; this . commandResult = result ; this . commandExitStatus = p . exitValue ( ) ; p . destroy ( ) ; if ( p . isAlive ( ) ) { p . destroyForcibly ( ) ; } }
Runs a command locally