Binary reading from stdin
[1/4] from: andreas:bolka:gmx at: 17-Feb-2002 22:07
Hi REBOLs!
I'm trying to write a program that reads binary data from fd 0
(stdin). Is there any way to accomplish that with REBOL?
--
Best regards,
Andreas mailto:[andreas--bolka--gmx--net]
[2/4] from: g:santilli:tiscalinet:it at: 18-Feb-2002 12:44
At 22.07 17/02/02, you wrote:
>I'm trying to write a program that reads binary data from fd 0
>(stdin). Is there any way to accomplish that with REBOL?
stdin is system/ports/input. You'll have to do something like:
set-modes system/ports/input [binary: yes]
data: copy system/ports/input
You'll need to set it back to string if you need to get input from
the user later (but it's likely you don't, if you're piping data
from another process).
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r
[3/4] from: andreas::bolka::gmx::net at: 18-Feb-2002 18:42
Monday, February 18, 2002, 12:44:54 PM, Gabriele wrote:
>>I'm trying to write a program that reads binary data from fd 0
>>(stdin). Is there any way to accomplish that with REBOL?
> stdin is system/ports/input. You'll have to do something like:
> set-modes system/ports/input [binary: yes]
> data: copy system/ports/input
that's exactly what i do - but it does not seem to work. i'm quite
sure that it's the fault of my program (not the callers fault).
. set-modes system/ports/input [ binary: true lines: false ]
. probe get-modes system/ports/input [ binary lines ]
. probe copy/part system/ports/input 8
; [binary: true lines: false]
; #{}
when i try to read-io, read-io returns -1. system/ports/input looks as
attached:
. probe system/ports/input
[i replaced every occurrence of paths with /path/to/script]
make object! [
scheme: 'file
host: none
port-id: none
user: none
pass: none
target: %input
path: %/path/to/script/
proxy: none
access: none
allow: none
buffer-size: none
limit: none
handler: none
status: none
size: none
date: none
url: none
sub-port: none
locals: none
state:
make object! [
flags: 67633697
misc: [0 0 "/path/to/script/input"]
tail: 0
num: 0
with: "^/"
custom: none
index: 0
func: 1
fpos: 0
inBuffer: none
outBuffer: none
]
timeout: none
local-ip: none
local-service: none
remote-service: none
last-remote-service: none
direction: none
key: none
strength: none
algorithm: none
block-chaining: none
init-vector: none
padding: none
async-modes: none
remote-ip: none
local-port: none
remote-port: none
backlog: none
device: none
speed: none
data-bits: none
parity: none
stop-bits: none
rts-cts: true
user-data: none
awake: none
]
--
Best regards,
Andreas mailto:[andreas--bolka--gmx--net]
[4/4] from: g:santilli:tiscalinet:it at: 19-Feb-2002 11:09
At 18.42 18/02/02, you wrote:
>that's exactly what i do - but it does not seem to work. i'm quite
>sure that it's the fault of my program (not the callers fault).
How is your program called? On what platform?
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r