standard input and output

Showing 1-6 of 6 messages
standard input and output Teemu Ikonen 5/2/12 4:10 AM
Hi,

We needed way to control phantomjs binary by stdin and stdout for using it as queued rendering engine and noticed that reading from /dev/stdin and /dev/stdout with require('fs').open('/dev/stdin').readLine() didn't work as expected and blocked until end of file mark. Also those device files are not available in all platforms. I added stdin, stdout and stderr file objects as standard members to filesystem object, so its possible to do this:

var stdin = require('fs').stdin();

var line;
while( line = stdin.readLine() ) {
   console.log( line );
}

I would like to get this or something similar on the main release, any comments if it's right approach for stdout/stdin or how to improve this?

Thanks, Teemu I.

Re: standard input and output Milian Wolff 5/2/12 5:02 AM
If I understand this correctly: http://wiki.commonjs.org/wiki/System/1.0

Then these methods should be in the system module.

cheers
Re: standard input and output Teemu Ikonen 5/2/12 5:43 AM
Good point, I'll move the stdin/err/out as objects in system module

var stdin = require('system').stdin;

var line;
while( line = stdin.readLine() ) {
   console.log( line );
}

/Teemu
Re: standard input and output Ariya Hidayat 5/2/12 4:34 PM
See also http://code.google.com/p/phantomjs/issues/detail?id=333 (and
the linked pull request). It's already almost fully implemented, just
needs some clean-up.



--
Ariya Hidayat, http://ariya.ofilabs.com
http://twitter.com/ariyahidayat
Re: standard input and output Teemu Ikonen 5/3/12 9:07 PM
Thanks for update, I'll wait for the release!

/Teemu
Re: standard input and output Ariya Hidayat 5/3/12 9:22 PM
Note that you are also free to improve the proposed pull request (it's
not completely done yet).


Regards,