lex@philica.ica.philips.nl (Lex van Sonderen) (03/06/91)
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
naughton@wind.Eng.Sun.COM (Patrick Naughton) (03/07/91)
'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