throw new Exception("error occurred processing parameters: " + e.getMessage());
}
}
protected boolean remoteIsWindowsShell() {
Session session = null;
try {
String checkShellCommand = "echo %ComSpec%";
getLogger().debug9("Opening ssh session...");
session = this.getSshConnection().openSession();
getLogger().debug9("Executing command " + checkShellCommand);
session.execCommand(checkShellCommand);
getLogger().debug9("output to stdout for remote command: " + checkShellCommand);
stdout = new StreamGobbler(session.getStdout());
stderr = new StreamGobbler(session.getStderr());
BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout));
String stdOut = "";
while (true) {
String line = stdoutReader.readLine();
if (line == null)
break;
getLogger().debug9(line);
stdOut += line;
}
getLogger().debug9("output to stderr for remote command: " + checkShellCommand);
// Beide StreamGobbler m�ssen hintereinander instanziiert werden
// InputStream stderr = new StreamGobbler(this.getSshSession().getStderr());
BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr));
while (true) {
String line = stderrReader.readLine();
if (line == null)
break;
getLogger().debug1(line);
}
if (stdOut.indexOf("cmd.exe") > -1) {
getLogger().debug3("Remote shell is Windows shell.");
return true;
}
}
catch (Exception e) {
try {
getLogger().warn("Failed to check if remote system is windows shell: " + e);
}
catch (Exception es) {
System.out.println(" Failed to check if remote system is windows shell: " + e);
}
}
finally {
if (session != null)
try {
session.close();
}
catch (Exception e) {
try {
getLogger().warn("Failed to close session: " + e);
}