Ask a Question
Advertise on boostr.in
Organizational Research By
Surprising Reserch Topic
Experts Most Trusted Topic
how to detect if a node js script is running through a shell pipe
how to detect if a node js script is running through a shell pipe Â using -'bash,node.js,pipe'
My question is similar to this one: How to detect if my shell script is running through a pipe?. The difference is that the shell script Iâ€™m working on is written in Node.js.
Letâ€™s say I enter:
echo "foo bar" | ./test.js
Then how can I get the value "foo bar" in test.js?
Iâ€™ve read Unix and Node: Pipes and Streams but that only seems to offer an asynchronous solution (unless Iâ€™m mistaken). Iâ€™m looking for a synchronous solution. Also, with this technique, it doesnâ€™t seem very straightforward to detect if the script is being piped or not.
TL;DR My question is two-fold:
How to detect if a Node.js script is running through a shell pipe, e.g. echo "foo bar" | ./test.js?
If so, how to read out the piped value in Node.js?
Â Â Â Â
Sep 18, 2015
to add a comment.
Related Hot Questions
Walkin Jobs Opening
Government Jobs Opening