Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!sun!exodus!wind!naughton From: naughton@wind.Eng.Sun.COM (Patrick Naughton) Newsgroups: comp.windows.news Subject: Re: wanted: pipe operator example Message-ID: <9202@exodus.Eng.Sun.COM> Date: 6 Mar 91 17:49:40 GMT References: <1991Mar5.024148.18582@quorum.com> <755@philica.ica.philips.nl> Sender: news@exodus.Eng.Sun.COM Reply-To: naughton@wind.Eng.Sun.COM (Patrick Naughton) Organization: Sun Microsystems, Inc. - Mountain View, CA Lines: 51 'readstring' is waiting for exactly 100 characters... (redbook p. 201) This will work... (/bin/sh) pipe /w exch def /r exch def w (pwd\n) writestring w flushfile r 100 string readline pop == also note that you don't need to fork a new /bin/sh, you are already running one as the parent process of NeWS. So this will work as well... (pwd) pipe pop 100 string readline pop == -Patrick In article <755@philica.ica.philips.nl>, lex@philica.ica.philips.nl (Lex van Sonderen) writes: |> I want to use the pipe operator to open a shell, send a command, |> read the result, send a command, read the result etc... |> |> I do something like this: |> |> /trypipe { % -- -> -- |> (/bin/sh) pipe % readfile writefile |> dup (pwd) writestring % readfile writefile |> dup flushfile % readfile writefile |> 1 index 100 string readstring { % readfile writefile str |> == % readfile writefile |> } { |> pop (nothing\n) == % readfile writefile |> } ifelse |> % now write some more commands |> % .... |> pop pop % -- |> } def |> |> Apparently, the operator gets stuck in readstring, no error messages. |> Closing the writefile before reading the readfile does help, but I |> want to keep it open. |> Help! |> |> Lex van Sonderen |> lex@ica.philips.nl -- ______________________________________________________________________ Patrick J. Naughton email: naughton@sun.com Sun Laboratories voice: (415) 336 - 1080