int exitCode = DEFAULT_EXIT_CODE;
String outputString = "";
try {
mSessionLock.lock();
final Session thisSession;
try {
thisSession = sess;
} finally {
mSessionLock.unlock();
}
if (thisSession == null) {
return new SshOutput("", 130);
}
/* requestPTY mixes stdout and strerr together, but it works
better at the moment.
With pty, the sudo wouldn't work, because we don't want
to enter sudo password by every command.
(It would be exposed) */
thisSession.requestPTY("dumb", 0, 0, 0, 0, null);
LOG.debug2("execOneCommand: command: "
+ host.getName()
+ ": "
+ host.getSudoCommand(host.getHoppedCommand(oneCommand), true));
thisSession.execCommand("bash -c '"
+ Tools.escapeSingleQuotes("export LC_ALL=C;"
+ host.getSudoCommand(host.getHoppedCommand(oneCommand),
false), 1) + '\'');
outputString = execCommandAndCaptureOutput(oneCommand, thisSession);
if (cancelIt) {
return new SshOutput("", 130);
}
if (commandVisible) {
host.getTerminalPanel().nextCommand();
}
thisSession.waitForCondition(ChannelCondition.EXIT_STATUS, 10000);
final Integer ec = thisSession.getExitStatus();
if (ec != null) {
exitCode = ec;
}
thisSession.close();
sess = null;
} catch (final IOException e) {
LOG.appWarning("execOneCommand: " + host.getName() + ':' + e.getMessage() + ':' + oneCommand);
exitCode = ERROR_EXIT_CODE;
cancelTheSession();