reading binary from STDIN in windows

W

Wybo Dekker

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)
 
S

Shashank Date

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 said:
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)




____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
 
W

Wybo Dekker

Try this:

ruby -e 'STDIN.binmode;i=STDIN.read;
open("test.pdf","wb").write(i)' < some.pdf

Notice how binmode sets the binary mode.

that works, thanks!
(I had been scanning STDIN's available methods but missed it...)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top