ecn-ec:malcolm@pur-ee.UUCP (09/20/83)
#N:ecn-ec:6400003:000:655
ecn-ec!malcolm Sep 20 02:09:00 1983
Can anybody tell me how to use the process routine in Franz Lisp to
set up a pipe to a process? An example of it in use would be a big
help.
In the lisp library sources I found a sample call that works without
the pipe args, but I still don't understand what it is trying to do.
The system version (that works) is
(apply 'process (ncons (concat "/bin/echo " PlotDevice))) .
Why isn't this the same as
(process (ncons (concat "/bin/echo " PlotDevice))) ?
or even
(process (concat "/bin/echo " PlotDevice))
Thanks for your help.
Malcolm Slaney
Purdue EE Dept.
{ucbvax,ihnp4,decvax,harpo}!
pur-ee!malcolm
mgs@purdueisrael@umcp-cs.UUCP (09/22/83)
Here's a function that I wrote called 'gwd' that gets the current
working directory by calling 'pwd'.
(defun gwd ()
(prog (a b c)
(process pwd a b) ; run 'pwd', input pipe is variable 'a', output is 'b'
(setq c (read b)) ; read output
(close a) ; close off pipes (they aren't closed automatically)
(close b)
(return c)))
--
~~~ Bruce
Computer Science Dept., University of Maryland
{rlgvax,seismo}!umcp-cs!israel (Usenet) israel.umcp-cs@Udel-Relay (Arpanet)jed@utah-cs.UUCP (Jed Krohnfeldt) (09/22/83)
I typically use process in the following way:
(process command from-pipe to-pipe)
where command is the unix command to be executed
from-pipe is a franz port opened for writing to the command
to-pipe is a franz port opened for reading from the command
The two ports, from and to, are opened by process and can subsequently be
used to write to and read from the command. So (patom "foo" from-pipe) will
write the string "foo" to the command, and (ratom to-pipe) will read the
next atom coming from command.
If the command needs to be executed with arguments, simply escape the space
between the command and its arguments:
(process ls\ -aslF)
For a simple example, try writing a C program that does nothing but loop
endlessly, reading a string and writing that string back out again. Then
use process to set up a from and to port to that program. Now, write
to the program using (patom "something" from) followed by a read from the
program with (ratom to). What you get back should be identical to what
you gave it.
Jed Krohnfeldt
..!harpo!utah-cs!jed
krohnfeldt@utah-20liz@umcp-cs.UUCP (09/26/83)
The reason that (apply 'process (ncons (concat "/bin/echo " PlotDevice))) . works and not: (process (ncons (concat "/bin/echo " PlotDevice))) ? or (process (concat "/bin/echo " PlotDevice)) is that process is an nlambda and does not eval its arguments. To set up pipes to your call, do: (apply 'process (list (concat "/bin/echo " PlotDevice) 'to_pipe 'from_pipe)) Then, (read from_pipe) and (print to_pipe) do the expected things. Unfortunately, you'll have to declare from_pipe and to_pipe as special. It would be much easier if process were not an nlambda. -- -Liz Allen, U of Maryland, College Park MD Usenet: ...!seismo!umcp-cs!liz Arpanet: liz%umcp-cs@Udel-Relay
notes@ucbcad.UUCP (09/28/83)
#R:umcp-cs:-273000:ucbcad:8400001:000:505 ucbcad!jkf Sep 28 07:51:00 1983 We have had lambda versions of process for quite some time (I can't recall just when they were added). There is a *process function which is used when you want to set up read and write pipes, a *process-send function for when you just want to write (e.g. ((lambda (p) (print "Hi there" p) (close p)) (*process-send "write joe")) ) and *process-receive for when you just want to read (e.g. ((lambda (p) (setq cwd (read p)) (close p)) (*process-receive "pwd")) ) john foderaro