On Sep 6, 2009, at 6:17 AM, Brit Butler wrote:
> I wrote a script to manipulate CSV files today. At the top is the
> shebang line described at http://www.sbcl.info/manual/Shebang-Scripts.html
> but when run with ./myFaves.lisp I still see compiler output and
> ASDF requires completing. All I would like to see is the program
> output. I have tried putting (setf *compile-print* nil) and (setf
> *compile-verbose* nil) after the shebang line in the source file to
> no avail. Tobias Rittweiler suggested I ask about it here. I have
> posted the source (myFaves.lisp) along with the (edited for
> confidentiality) output I get (out.txt) and the output I would like
> to get (desired.txt) at http://redlinernotes.com/sbcl. Finally,
> "output.txt" contains the results of running "./myFaves.lisp >
> out.txt". I'd be happy to write a patch for the section in the
> Manual if someone would show me the ropes once this is figured out.
In my scripts I use the following macro:
(defmacro redirecting-stdout-to-stderr (&body body)
"Redirects *Standard-output*, *error-output* and *trace-output* to
a string stream, and catch errors while executing body.
If there is an error, then writes all the output to *error-output* and
exit,
otherwise return NIL.
"
(let ((verror (gensym))
(voutput (gensym)))
`(let* ((,verror nil)
(,voutput (with-output-to-string (stream)
(let ((*standard-output* stream)
(*error-output* stream)
(*trace-output* stream))
(handler-case (progn ,@body)
(error (err) (setf ,verror err)))))))
(when ,verror
(terpri *error-output*)
(princ ,voutput *error-output*)
(terpri *error-output*)
(princ ,verror *error-output*)
(terpri *error-output*)
(terpri *error-output*)
#-testing-script (sb-ext:quit :status 1)))))
--
__Pascal Bourguignon__
http://www.informatimago.com
|