Rings posted an example of how to redirect output from a DOS app into memory here: viewtopic.php?t=3704 and it works fine.. on Windows..
Is there a way to do this with Linux? I know I can pipe the output to a file and read it but I was hoping for a way similar to Rings solution. I thought I read that the newer versions of PB would be able to do this... hopefully I was not dreaming...
Redirect output into memory?
Redirect output into memory?
-Beach
It simpler than on Windows actually...
You can replace the fgets_() with any other libc command that works on streams
if you prefer another reading method.
Code: Select all
Command$ = "df -h"
Pipe = popen_(Command$, "r")
If Pipe
*Buffer = AllocateMemory(2000)
If *Buffer
Repeat
result = fgets_(*Buffer, 2000, Pipe)
If result
Debug PeekS(*Buffer)
EndIf
Until result = 0
EndIf
pclose_(Pipe)
Else
Debug "Error"
EndIf
You can replace the fgets_() with any other libc command that works on streams
if you prefer another reading method.
quidquid Latine dictum sit altum videtur
-
- Enthusiast
- Posts: 152
- Joined: Sun Jul 11, 2004 7:48 pm
- Location: Lillehammer, No(r)way
- Contact:
Shange the "r" to "w":
Then do something like:
Have no idead if it will work, but in theory it should.. 
Here's a link with some docs to the Linux api functions.. http://www.opengroup.org/onlinepubs/007908799/
Code: Select all
Pipe = popen_(Command$, "w") ; "w" = Write, "r" = Read
Code: Select all
*Buf = AllocateMemory(2000)
If *Buf
PokeS(*Buf, "test string")
res = fputs_(*Buf, Pipe) ; fputs_ = PutString (without newlinechar)
; puts_ = PutString.. (newlinechar)
EndIf

Here's a link with some docs to the Linux api functions.. http://www.opengroup.org/onlinepubs/007908799/
-
- Enthusiast
- Posts: 277
- Joined: Fri Jun 17, 2005 7:13 pm
- Location: Franconia
- Contact:
May I use your example in a GPL/LGPL program?freak wrote:It simpler than on Windows actually...
Code: Select all
...
You can replace the fgets_() with any other libc command that works on streams
if you prefer another reading method.
-
- Enthusiast
- Posts: 277
- Joined: Fri Jun 17, 2005 7:13 pm
- Location: Franconia
- Contact: