On Sat Jul 16, 2005 at 01:15:03AM +0200, Edi Weitz wrote:
That doesn't work without Lisp either:
edi@miles:/tmp$ bash echo "Hello World" > tmp /bin/echo: /bin/echo: cannot execute binary file
Try this instead:
(ext:run-program "bash" '("-c" "echo "Hello World" > tmp") :output *standard-output*)
Actually, I was rather thinking about invoking a shell script:
edi@miles:/tmp$ rm foo edi@miles:/tmp$ cat foo.sh echo "Hello World" > /tmp/foo edi@miles:/tmp$ cmucl
- (ext:run-program "sh" '("foo.sh") :output *standard-output*)
#<process 4501 :EXITED>
- (quit)
edi@miles:/tmp$ cat foo Hello World
That works. Thanks!
--Jeff
Hi Jeff,
Jeff Cunningham jeffrey@cunningham.net writes:
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:
[...]
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*):
My version of cdrdao seems to write its output to stderr, not stdout, so the above output is probably coming from your ":error t" argument. I'm not completely sure what you want to do, but this sort of approach seems to work for me:
(with-open-stream (rip (ext:process-error (ext:run-program "cdrdao" '("read-test" "-v" "1" "test-toc.toc") :output nil :wait nil :error :stream))) (loop as line = (read-line rip nil) while line do (dolist (output-line (split (string #\Return) line)) (when (cl-ppcre:scan "^Read \d+ of \d+ MB." output-line) (write-line output-line)))))
Cheers,
Mark
On Sun Jul 17, 2005 at 11:22:27AM +1000, Mark Triggs wrote:
My version of cdrdao seems to write its output to stderr, not stdout, so the above output is probably coming from your ":error t" argument. I'm not completely sure what you want to do, but this sort of approach seems to work for me:
(with-open-stream (rip (ext:process-error (ext:run-program "cdrdao" '("read-test" "-v" "1" "test-toc.toc") :output nil :wait nil :error :stream))) (loop as line = (read-line rip nil) while line do (dolist (output-line (split (string #\Return) line)) (when (cl-ppcre:scan "^Read \d+ of \d+ MB." output-line) (write-line output-line)))))
Hi Mark,
That works on my machine as well. I was looking at the wrong stream :[
Thanks!
--Jeff