So I made a macro to help me execute perl scripts remotely(FTP vis SSH) from Komodo. It works fine normally and I get STDOUT just fine, but when there is any kind of error, STDERR and STDOUT is blank.
Here is my macro below:
print_to_output_tab = function(str) {
try {
ko.run.output.show(window, false);
var runWidgetDoc = ko.widgets.getWidget("runoutput-desc-tabpanel").contentDocument;
var deckWidget = runWidgetDoc.getElementById("runoutput-deck");
if (deckWidget.getAttribute("selectedIndex") != 0) {
ko.run.output.toggleView();
}
var scimoz = runWidgetDoc.getElementById("runoutput-scintilla").scimoz;
var prevLength = scimoz.length;
var currNL = ["\r\n", "\n", "\r"][scimoz.eOLMode];
var full_str = str + currNL;
var full_str_byte_length = ko.stringutils.bytelength(full_str);
var ro = scimoz.readOnly;
try {
scimoz.readOnly = false;
scimoz.clearAll();
scimoz.appendText(full_str_byte_length, full_str);
} finally {
scimoz.readOnly = ro;
}
scimoz.gotoPos(prevLength + 1);
} catch(ex) {
alert("problems printing [" + str + "]:" + ex + "\n");
} };
function getRemoteSSHConnection() {
var remoteConnectionSvc = Components.classes["@activestate.com/koRemoteConnectionService;1"].
getService(Components.interfaces.koIRemoteConnectionService);
var view = ko.views.manager.currentView;
var uri = view.document && view.document.file.URI || view.koDoc.file.URI; // Support K7 koDoc
if (uri.substr(0, 1) != "s") {
throw Error("The current file is not a remote SSH file. Open a remote file first.");
}
var conn = remoteConnectionSvc.getConnectionUsingUri(uri);
if (conn) {
conn.QueryInterface(Components.interfaces.koISSHConnection);
}
return conn
}
var stdout = {};
var stderr = {};
var filePath = ko.views.manager.currentView.koDoc.displayPath;
var re = new RegExp('^sftp://.*?(/.*?)$','');
var dirPath = filePath.replace(re,'$1');
var conn = getRemoteSSHConnection();
var retval = conn.runCommand( 'perl '+dirPath, false, stdout, stderr);
alert( JSON.stringify(conn) );
print_to_output_tab(stdout.value + "\n-error-\n" + stderr.value);