I want to send a buffer as a piped input to a node script on the terminal. Thus I created a script ping.js with the following code:
#!/usr/local/bin/node
function bufferDemo() {
var objBuffer = new Buffer(29);
objBuffer.writeUInt32LE(29,0);
objBuffer.write('{message:"pingfrompingjs"}',4);
return objBuffer;
}
bufferDemo();
Then I ran the following command on the command line:
./ping.js | ./index.js
I also tried:
./ping.js > out.json
out.json is empty so obviously the ping.js is not passing the buffer. How do I achieve this? I am relatively new to node.