[erlang-questions] how: binary from pipe in os:cmd

Miguel Rodríguez Rubinos <>
Mon Jan 14 20:41:14 CET 2008


Hello all,

I'd like to read a binary from 'os:cmd("some_command with_args -")'.
This generates a binary that is sent through stdout as result.

The problem is that 'os:cmd' seems to stop reading when bytes 0x00
(NULL) or 0x04 (EOT) are found. So, usually, it doesn't return the
entire binary.

Has anybody idea of how to do this? I would like to read the entire
binary, not only the first N characters until 0x00 or 0x04.

For example, if you type

33> length(os:cmd("lame --silent bark.wav -")).    
135

Tha character at position 135 of resulting mp3 is 0x04. Besides,
full mp3 size should be 576 bytes.

Thanks in advance.

Cheers,

	Miguel

-- 
Miguel Rodríguez Rubinos <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bark.wav
Type: audio/x-wav
Size: 2411 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080114/ebfba75a/attachment.wav>


More information about the erlang-questions mailing list