Re: How to get stdout into gforth

carl hansen <[email protected]>
Newsgroups gmane.comp.lang.forth.gforth
Message-ID <CAHEkXCQ_C5UPRonyXb8-ZPUYF2iOYEhbvLJ7TqcQSM10KgKV4Q@mail.gmail.com>
On Thu, Jan 25, 2018 at 2:49 PM, Dennis Ruffer <[email protected]> wrote:

> Say I want to do something like this:
>
>
>
> s" cd .. ; pwd" system /home/druffer
>
>
>
> How do I get the output of pwd back into gforth?
>
>
>
> I see infile-execute, but I don’t see an examples for me to try.
>
>
>
> Is that the right path, or is there another?
>
>
>
> DaR
>
>
>
>
​here's one idea: write to a file ie "pwd >foo"
then read back the file, as so:

​#! /usr/bin/env gforth

s" foo" r/w create-file

drop  \ really should check for errors

variable fileid
fileid !

s" echo You think this works\?  >foo ; pwd >>foo " system

create filecontents 200 allot
filecontents 200 fileid @ read-file

filecontents 200 type
filecontents 100 dump

fileid @ close-file

bye

​There probably is a way to do it with pipes, but it is beyond me.​
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.