+ String fn = "SshJcraftWrapper.send";
+ OutputStream out = channel.getOutputStream();
+ DataOutputStream dos = getDataOutputStream(out);
+ if ((cmd.charAt(cmd.length() - 1) != '\n') && (cmd.charAt(cmd.length() - 1) != '\r')) {
+ cmd += "\n";
+ }
+ int length = cmd.length();
+ int i = -1;
+ int nchars = 300000;
+ int ncharsTotalSent = 0;
+ int ncharsSent = 0;
+
+ appendToFile(debugLogFileName, fn + ": Sending: '" + cmd);
+ DebugLog.printRTAriDebug(fn, "Length of cmd is:" + length); // 2,937,706
+ try {
+ if (length > 600000) {
+ int timeout = 9000;
+ for (i = 0; i < length; i += nchars) {
+ String Cmd = cmd.substring(i, Math.min(length, i + nchars));
+ ncharsSent = Cmd.length();
+ ncharsTotalSent = ncharsTotalSent + Cmd.length();
+ DebugLog.printRTAriDebug(fn, "i=" + i + " Sending Cmd: ncharsSent=" + ncharsSent);
+ dos.writeBytes(Cmd);
+ dos.flush();
+ try {
+ DebugLog.printRTAriDebug(fn, ":::i=" + i + " length=" + length);
+ if (ncharsSent < length) {
+ receiveUntilBufferFlush(ncharsSent, timeout, "buffer flush i=" + i);
+ } else {
+ DebugLog.printRTAriDebug(fn, "i=" + i + " No Waiting this time....");
+ dos.flush();
+ }
+ } catch (Exception e) {
+ DebugLog.printRTAriDebug(fn, "Caught an Exception: Nothing to flush out.");
+ }
+ }
+ } else {
+ DebugLog.printRTAriDebug(fn, "Before executing the dos.writeBytes");
+ dos.writeBytes(cmd);
+ }
+ dos.flush();
+ DebugLog.printRTAriDebug(fn, "Leaving method");
+ appendToFile(debugLogFileName, fn + ": Leaving method\n");