[Openmcl-devel] where is shell output stored when launching an external program?
Mark Cox
markcox80 at gmail.com
Tue Apr 17 15:21:16 PDT 2012
Hi Clayton,
On Tue, Apr 17, 2012 at 11:00 AM, clayton stanley
<cstanley at cstanley.no-ip.biz> wrote:
> I am launching external processes with clozure common lisp. For better feedback/debugging, I would like to display the bash error string when I try to execute a nonexistent binary.
Can't this be solved using PROBE-FILE?
(defvar *path-to-program* nil)
(defun path-to-program ()
(let ((v (probe-file (or *path-to-program*
(merge-pathnames (make-pathname :name "my-program"
:directory '(:relative "bin"))
(asdf:system-source-directory "my-system"))))))
(unless v
(error "PATH-TO-PROGRAM failed to find executable"))
v))
(defun run-program (&rest args)
(ccl:run-program (path-to-program) args))
Or substitute PROBE-FILE with a cross platform implementation of
FILE-EXISTS-AND-IS-EXECUTABLE-P?
Mark
>
> For example:
>
> ? (setf *t* (run-program "programDoesNotExist" '() :output t :error :output :wait nil))
> #<EXTERNAL-PROCESS (programDoesNotExist)[919] (RUNNING) #x302000E6471D>
>
> ? *t*
> #<EXTERNAL-PROCESS (programDoesNotExist)[919] (EXITED : 71) #x302000E6471D>
>
> ? (inspect *t*)
> [0] #<EXTERNAL-PROCESS (programDoesNotExist)[919] (EXITED : 71) #x302000E6471D>
> [1] Type: EXTERNAL-PROCESS
> [2] Class: #<STRUCTURE-CLASS EXTERNAL-PROCESS>
> [3] PID: 919
> [4] %STATUS: :EXITED
> [5] %EXIT-CODE: 71
> [6] PTY: NIL
> [7] INPUT: NIL
> [8] OUTPUT: NIL
> [9] ERROR: NIL
> [10] STATUS-HOOK: NIL
> [11] PLIST: NIL
> [12] TOKEN: (0)
> [13] CORE: NIL
> [14] ARGS: ("programDoesNotExist")
> [15] SIGNAL: #<SEMAPHORE #x302000E6483D>
> [16] COMPLETED: #<SEMAPHORE #x302000E647BD>
> [17] WATCHED-FDS: NIL
> [18] WATCHED-STREAMS: NIL
> [19] EXTERNAL-FORMAT: #<EXTERNAL-FORMAT NIL/:UNIX #x30200049FE9D>
> Inspect>
>
> Even with the inspector, I can't find the error information printed by the shell. I'm trying to recover this string in the lisp process:
>
> $ programDoesNotExist
> -bash: programDoesNotExist: command not found
>
> Any help would be greatly appreciated.
>
> Thanks,
> -Clayton
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
More information about the Openmcl-devel
mailing list