Re: How to get a process output into a variable?

On Mon, Apr 12, 2004 at 11:31:27PM -0600, Michal Jaegermann wrote:
> I wanted to use an output of some program as a value of a variable
> or an argument to a function call.  After trying to understand
> librep documentation it started to look to me that something rougly
> like that should work ('cat' is here emulating a general situation;
> I know that below I do not have to use null):
> (let ((proc (make-process standard-output)))
>   (call-process proc null "cat" "/tmp/data")
>   (let ((var (read-line standard-output)))
>     (print var)))

You want something like

  (let* ((str  (make-string-output-stream))
         (proc (make-process str)))
    (call-process proc nil "cat" "/tmp/data")
    (let ((var (get-output-stream-string str)))
      (print var)))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]