Reputation: 1230
I have a node project where I output a filename to stdout
in the terminal with process.stdout.write(filename + '\n');
. How can I pipe this output to the open
command or some other command to open the file (an image in this case) with the default image viewer?
Upvotes: 0
Views: 1670
Reputation: 997
As Mark Setchell points out in the comments, you will need to pass -a <appname>
to open the file with a specific application.
However, you will need to pipe the file to stdout instead of just the filename, fore example like this:
var fs = require('fs');
fs.createReadStream("./test.jpg").pipe(process.stdout);
and then of yourse node yourNodeFile.js | open -f -a Preview.app
Upvotes: 1