Thursday, 1 June 2017

Taking simple shell input with javascript

I'm trying to take simple input from a linux shell when a javascript program is run. I've tried using readline() and prompt() but both of those throw Reference Error: readline() is not defined or prompt() is not defined.

//Decode Bluetooth Packets

var advlib = require('advlib');
console.log("What data to process - If you respond N than what is written inline will be decoded");
var input = require();
if (input != "N") {

    var rawHexPacket = input
    var processedpacket = advlib.ble.process(rawHexPacket);
    console.log(JSON.stringify(processedpacket,null, " "));
}
else {  
    //Put in raw data here!
    var rawHexPacket = 'dfasdfasdfasd4654df3asd3fa3s5d4f65a4sdf64asdf';
    var processedpacket = advlib.ble.process(rawHexPacket);
    console.log(JSON.stringify(processedpacket,null, " "));
}

So what is a simple way to get javascript input through a linux shell?



via fencingparry4

No comments:

Post a Comment