Skip to content

Instantly share code, notes, and snippets.

@gorvelyfab
Last active October 3, 2019 12:51
Show Gist options
  • Save gorvelyfab/7dc7f12b96a49b154fa6c1068ba5cfee to your computer and use it in GitHub Desktop.
Save gorvelyfab/7dc7f12b96a49b154fa6c1068ba5cfee to your computer and use it in GitHub Desktop.
copy and paste into console | DigitalOcean droplets https://www.digitalocean.com/community/questions/copy-and-paste-into-console
// the wizare functions
var sendString = (function(rfb, force, sendDelay) {
sendDelay = sendDelay || 25;
var _q = [];
var _qStart = function() {
var chr = _q.shift();
if (chr) {
rfb.sendKey(chr);
setTimeout(_qStart, sendDelay);
}
};
var _qStop = function() { _q.length = 0; };
var fn = function sendString(str) {
_qStop();
str = str || '';
var chr;
for (var i=0; i < str.length; i++) {
chr = str[i].charCodeAt();
_q.push(chr);
}
_qStart();
};
if (rfb.sendString && true !== force) {
console.warn('rfb.sendString not installed because it already exists. Use force if you\'d like');
}
else {
rfb.sendString = fn;
}
return fn;
})(rfb);
// Commandline to be pasted in the console
sendString("Commandline to be pasted in the console")
Copy link

ghost commented Oct 3, 2019

Try sendString("@") it sends 2 to the console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment