How to get a process output into a variable?



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)))

but this is really not the case and 'var' is still undefined.  The
same for a similar stuff where start-process is used instead.  What
I am missing here?  'let*' does not make a difference but I am
clutching straws here. As far as I can see the issue is not a scope
or something like that but that (read-line ...) is not really
reading anything and data are dumped instead on my screen.
Do I have to create my own output-stream variable?  It is still
far from clear that (read-line ...) will be able to use it or
at least I am unable to make it.

I tried to find some code examples but I am not much wiser so far.
'ispell.jl' does tons of other things. Yes, I actually need to
retrieve a single number in a reasonably simple manner although
a basic error checking would be nice.

   Michal



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