Pooh program example 11-file-pipe.p
# run process and script send data to it via stdin and read stdout f = openpipe( ~cmdline 'tr a A' ) f.write( ~towrite 'aaaaaaa' ~numwrite 7 ) f.closewrite() output = emptystring() f.read( ~toread output ~numread 7 ) status = f.wait() println( ~msg 'output: [ output ] status: [ status ]' )
output: AAAAAAA status: 0Trace output for 11-file-pipe.p
003|... = openpipe( ~cmdline 'tr a A' )... 003|f = openpipe( ~cmdline 'tr a A' ):-> { 'read' : sub read(, 'closeread' : sub closeread(, '' : 136458616, 'wait' : sub wait(, 'finalize' : sub finalize(, 'write' : sub write(, 'closewrite' : sub closewrite(, 'pid' : 29898 } 005|f{'write'}:sub write(( ~towrite 'aaaaaaa' ~numwrite 7 )... 005|f{'write'}:sub write(( ~towrite 'aaaaaaa' ~numwrite 7 ):7 007|f{'closewrite'}:sub closewrite(( )... 007|f{'closewrite'}:sub closewrite(( ):Null 009|... = emptystring( )... 009|output = emptystring( ):'' 011|f{'read'}:sub read(( ~toread output:'' ~numread 7 )... 011|f{'read'}:sub read(( ~toread output:'' ~numread 7 ):7 013|... = f{'wait'}:sub wait(( )... 013|status = f{'wait'}:sub wait(( ):0 015|println( ~msg 'output: ' .. output:'AAAAAAA' .. ' status: ' .. status:0 .. '' )...