<commit_before>/**
 * Run this macro with a remote file open to execute an SSH command on the remote server.
 *
 * @source https://github.com/Komodo/macros
 * @author <NAME>
 * @contributor <NAME>
 * @version 0.4
 */

function  getRemoteSSHConnection() {
    var remoteConnectionSvc = Components.classes["@activestate.com/koRemoteConnectionService;1"].
            getService(Components.interfaces.koIRemoteConnectionService);
    // Use the current file's URI.
    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) {
        // Ensure it's an SSH connection
        conn.QueryInterface(Components.interfaces.koISSHConnection);
    }
    else
    {
        throw Error("Not an SSH connection.  Please open the file through SSH.");
    }
    return conn
}
var conn = getRemoteSSHConnection();
var stdout = {};
var stderr = {};
var retval = conn.runCommand("ls -la", false, stdout, stderr);

ko.notifications.add('Remote Run Command',
                     ['Remote Command', "Macro Monday"],
                     'remote_run_command',
                     { severity : Components.interfaces.koINotification.SEVERITY_INFO, description : stdout.value });<commit_msg>Add new function<commit_after>/**
 * Run this macro with a remote file open to execute an SSH command on the remote server.
 *
 * @source https://github.com/Komodo/macros
 * @author <NAME>
 * @contributor <NAME>, <NAME>
 * @version 0.4
 */

function getRemoteSSHConnection() {
    var remoteConnectionSvc = Components.classes["@activestate.com/koRemoteConnectionService;1"].
            getService(Components.interfaces.koIRemoteConnectionService);
    // Use the current file's URI.
    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) {
        // Ensure it's an SSH connection
        conn.QueryInterface(Components.interfaces.koISSHConnection);
    }
    else
    {
        throw Error("Not an SSH connection. Please open the file through SSH.");
    }
    return conn
}
var conn = getRemoteSSHConnection();
var stdout = {};
var stderr = {};
var command = prompt("Type a command: ");
(command.trim() == "") ? command = "ls -la" : command = command;
var retval = conn.runCommand(command, false, stdout, stderr);

ko.notifications.add('Remote Run Command',
                     ['Remote Command', "Macro Monday"],
                     'remote_run_command',
                     { severity : Components.interfaces.koINotification.SEVERITY_INFO, description : stdout.value });

{'fraction_non_alphanumeric': 0.12039473684210526, 'fraction_numerical': 0.003947368421052632, 'mean_word_length': 2.980366492146597, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2045496', 'n_tokens_mistral': 893, 'n_tokens_neox': 868, 'n_words': 249}