Windows again -(
How can I read a binary file from STDIN?
For example, in linux I can copy some.pdf to test.pdf:
ruby -e 'i=STDIN.read; open("test.pdf","w").write(i)' <some.pdf
in windows I can (and must) use "wb" instead of "w", but how do I specify
STDIN to be binary?
(I need this for a filter working on pdf-files)
···
--
Wybo
Try this:
ruby -e 'STDIN.binmode;i=STDIN.read;
open("test.pdf","wb").write(i)' < some.pdf
Notice how binmode sets the binary mode.
-- shanko
···
--- Wybo Dekker <wybo@servalys.nl> wrote:
Windows again -(
How can I read a binary file from STDIN?
For example, in linux I can copy some.pdf to
test.pdf:
ruby -e 'i=STDIN.read;
open("test.pdf","w").write(i)' <some.pdf
in windows I can (and must) use "wb" instead of "w",
but how do I specify
STDIN to be binary?
(I need this for a filter working on pdf-files)
--
Wybo
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
that works, thanks!
(I had been scanning STDIN's available methods but missed it...)
···
On Fri, 24 Jun 2005, Shashank Date wrote:
Try this:
ruby -e 'STDIN.binmode;i=STDIN.read;
open("test.pdf","wb").write(i)' < some.pdf
Notice how binmode sets the binary mode.
--
Wybo