I was attempting to implement this as a proof of concept and I'm able to create the crosh terminal process with chrome.terminalPrivate.openTerminalProcess. I believe I'm starting the bash shell, but I don't think the command "touch ~/Downloads/test.txt" is run because the file isn't created. Is there anything special I'm missing? I'm using the Secure Shell dev-id to get access to the chrome.terminalPrivate class.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var shellCommand = 'shell\n';
var croshName = 'crosh';
window.onload = function() {
Crosh(null);
commandTest();
}
function Crosh(argv) {
this.argv_ = argv;
this.io = null;
this.keyboard_ = false;
this.pid_ = -1;
}
function commandTest() {
chrome.terminalPrivate.onProcessOutput.addListener(processListener);
chrome.terminalPrivate.openTerminalProcess(croshName, (pid) => {
if (pid < 0) {
window.alert("error!");
}
this.pid_ = pid;
var cmd1 = 'shell\n';
var cmd2 = 'touch ~/Downloads/test.txt\n';
chrome.terminalPrivate.sendInput(pid, cmd1,
function (r1) {
window.alert(r1);
}
);
chrome.terminalPrivate.sendInput(pid, cmd2,
function (r2) {
window.alert(r2);
}
);
chrome.terminalPrivate.closeTerminalProcess(
this.pid_,
function(result) {
window.alert(result);
}
);
});
}
function processListener(pid, type, text){
window.alert(text);
}