[slime-devel] Re: Handling ^M and ^H characters output from ext:run-program?

Jeff Cunningham jeffrey at cunningham.net
Sat Jul 16 20:36:30 UTC 2005


On Sat Jul 16, 2005 at 10:24:08AM -0700, GP lisper wrote:
> >
> > (with-open-stream (rip
> >                    (ext:process-output
> >                     (ext:run-program "cdrdao"
> >                                      `("read-test" "-v" "1" "--device"
> 
> This needs to be a list, I'm not up enough on backtick tricks to know
> if it is.  Double check in the process list (something similar to "top
> -c" with a fast rep rate) that the proper arguments appear.
> 
> >                                        ,*burner-scsi-id* ,tocfile)
> >                                      :output :stream
> >                                      :wait nil
> >                                      :error t)))
>     (when rip
>       (loop for line = (read-line rip nil)
> 	    while line do 
>  	     (format t "~a~%" line))
>       (close rip)))
> 
> Is ~ what I use daily.  I built it up playing in the REPL.


It is a list. The command runs fine, its just filtering its output
which is problematic. Here's the only thing I've been able to make
work even remotely the way I want it to:

(let ((rip (ext:process-output
            (ext:run-program "cdrdao"
                             '("read-test" "-v" "1" "--device" "0,6,0" "p7.toc")
                             :output :stream
                             :wait nil
                             :error t))))
  (do ((line (read-line rip nil 'done)
             (read-line rip nil 'done)))
      ((eql line 'eof))
    (let ((progress (scan-to-strings "^Read \\d+ of \\d+ MB." line)))
      (if progress
          (format t "~a~%" progress)
          (format t "~a~%" (subseq line 0 (1- (length line))))))))


This works - except that there's no graceful exit out of the do loop - it results in the following:

Cdrdao version 1.1.9 - (C) Andreas Mueller <andreas at daneb.de>

Starting read test...
Writing track 01 (mode AUDIO/AUDIO )...
Read 0 of 547 MB.
Read 36 of 547 MB.
Read 104 of 547 MB.
Read 264 of 547 MB.
Read 341 of 547 MB.
Read 418 of 547 MB.
Read 244218 blocks.

; Compilation unit aborted.

(After I kill the process in the *slime-repl*):

Type-error in KERNEL::OBJECT-NOT-TYPE-ERROR-HANDLER:
   DONE is not of type SEQUENCE
   [Condition of type TYPE-ERROR]

Restarts:
  0: [ABORT] Abort SLIME compilation.
  1: [ABORT-READ] Abort reading input from Emacs.
  2: [ABORT] Abort SLIME compilation.
  3: [ABORT] Abort handling SLIME request.
  4: [ABORT] Return to Top-Level.

Backtrace:
  0: (LENGTH 1 DONE)[:EXTERNAL]
  1: (SCAN-TO-STRINGS #<#1=unavailable-arg> #<#1#> :START #<#1#> ...)
  2: ("Top-Level Form")[:TOP-LEVEL]

There must be some way to exit that loop gracefully. I tried the loop construct suggested:


  (when rip
    (loop for line = (read-line rip nil)
          while line do
          (format t "~a~%" line))
    (close rip)))


but couldn't get it to work at all. In any event, why would you need
to close rip? Isn't it handled automatically by the 'with-open-stream
function?


--Jeff




More information about the slime-devel mailing list