Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #21723
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Gforth linux system pipes? |
| Date | 2013-04-18 00:28 +0200 |
| Organization | 1&1 Internet AG |
| Message-ID | <kkn7mk$l78$1@online.de> (permalink) |
| References | <492f4bba-1a59-45a0-afae-a285a00218dd@googlegroups.com> |
Philip Smith wrote:
> If i do the following in gforth:
>
> s" pgrep aprocessrunning" system
>
> I would get the PID of aprocessrunning. This displays the PID to the
> console i believe but my question is how do i get that value?
>
> First off i know i could from linux do this:
>
> $ pgrep aprocessrunning | gforth someprogram.fs
>
> And now the gforth program somepgrogram.fs can receive the pipe i used at
> the command line that is pipping into gforth but that is not what i want!
> What i want is to have someprogram.fs have all the system commands issued
> inside gforth.
>
> So i thought i could do this in gforth:
>
> s" pgrep aprocessrunning" r/w open-pipe throw pad 10 rot read-file throw
> pad swap type
>
> The problem here is that i do not know before hand the size of the PID
> returned to put into the read-file and this seems to not work anyways
> because r/w is a problem for open-pipe it seems. ( note in the example i
> do not close-pipe because i am just focusing on getting the data here)
What about r/o?
That's out of script.fs:
2Variable sh$ 0. sh$ 2!
: sh-get ( addr u -- addr' u' )
\G open command addr u, and read in the result
sh$ free-mem-var
r/o open-pipe throw dup >r slurp-fid
r> close-pipe throw to $? 2dup sh$ 2! ;
Usage
s" pgrep aprocessrunning" sh-get type
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
Gforth linux system pipes? Philip Smith <philipkingsmith@gmail.com> - 2013-04-17 14:49 -0700
Re: Gforth linux system pipes? Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-18 00:28 +0200
Re: Gforth linux system pipes? Philip Smith <philipkingsmith@gmail.com> - 2013-04-17 15:40 -0700
Re: Gforth linux system pipes? Philip Smith <philipkingsmith@gmail.com> - 2013-04-17 18:13 -0700
Re: Gforth linux system pipes? Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-22 19:00 +0200
Re: Gforth linux system pipes? Philip Smith <philipkingsmith@gmail.com> - 2013-04-25 17:54 -0700
Re: Gforth linux system pipes? Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-26 16:19 +0200
Re: Gforth linux system pipes? Philip Smith <philipkingsmith@gmail.com> - 2013-04-26 10:10 -0700
Re: Gforth linux system pipes? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-26 14:10 +0000
csiph-web