X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Futil%2FSystemCommandExecutor.java;h=a4cdec544986bc949c927b4c7aeac6866f7b9ad0;hb=13e111a104747fd3c5678aed95215a61c980b595;hp=bb87989d2cdb3e28ed250470bb37e4e91ab0d246;hpb=c6db1dfeb009e379b3b53425b65cc4d11f49c1e8;p=jalview.git diff --git a/forester/java/src/org/forester/util/SystemCommandExecutor.java b/forester/java/src/org/forester/util/SystemCommandExecutor.java index bb87989..a4cdec5 100644 --- a/forester/java/src/org/forester/util/SystemCommandExecutor.java +++ b/forester/java/src/org/forester/util/SystemCommandExecutor.java @@ -3,28 +3,28 @@ * This class can be used to execute a system command from a Java application. * See the documentation for the public methods of this class for more * information. - * + * * Documentation for this class is available at this URL: - * + * * http://devdaily.com/java/java-processbuilder-process-system-exec - * + * * Copyright 2010 alvin j. alexander, devdaily.com. - * + * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser Public License for more details. - * + * * You should have received a copy of the GNU Lesser Public License along with * this program. If not, see . - * + * * Please see the following page for the LGPL license: * http://www.gnu.org/licenses/lgpl.txt - * + * */ package org.forester.util; @@ -38,14 +38,13 @@ import java.util.List; public class SystemCommandExecutor { private final List _command_information; - private final String _admin_password; private ThreadedStreamHandler _input_stream_handler; private ThreadedStreamHandler _error_stream_handler; private final static boolean DEBUG = false; /** * Pass in the system command you want to run as a List of Strings, as shown here: - * + * * List commands = new ArrayList(); * commands.add("/sbin/ping"); * commands.add("-c"); @@ -53,7 +52,7 @@ public class SystemCommandExecutor { * commands.add("www.google.com"); * SystemCommandExecutor commandExecutor = new SystemCommandExecutor(commands); * commandExecutor.executeCommand(); - * + * * Note: I've removed the other constructor that was here to support executing * the sudo command. I'll add that back in when I get the sudo command * working to the point where it won't hang when the given password is @@ -63,11 +62,10 @@ public class SystemCommandExecutor { */ public SystemCommandExecutor( final List command_information ) { if ( ( command_information == null ) || command_information.isEmpty() ) { - throw new IllegalArgumentException( "The commandInformation is required." ); + throw new IllegalArgumentException( "command information is required" ); } checkCmdFile( new File( command_information.get( 0 ) ) ); _command_information = command_information; - _admin_password = null; } public static boolean isExecuteableFile( final File path_to_cmd_f ) { @@ -114,9 +112,8 @@ public class SystemCommandExecutor { // these need to run as java threads to get the standard output and error from the command. // the inputstream handler gets a reference to our stdOutput in case we need to write // something to it, such as with the sudo command - _input_stream_handler = new ThreadedStreamHandler( inputStream, stdOutput, _admin_password ); + _input_stream_handler = new ThreadedStreamHandler( inputStream, stdOutput ); _error_stream_handler = new ThreadedStreamHandler( errorStream ); - // TODO the inputStreamHandler has a nasty side-effect of hanging if the given password is wrong; fix it _input_stream_handler.start(); _error_stream_handler.start(); // TODO a better way to do this? @@ -134,9 +131,9 @@ public class SystemCommandExecutor { // generated by process.waitFor() call throw e; } - // finally { + // finally { return exit_value; - // } + // } } /**