[Openmcl-devel] where is shell output stored when launching an external program?

Gary Byers gb at clozure.com
Mon Apr 16 22:00:46 PDT 2012


If you'd actually created lisp streams in your example, they'd
be in the slots named INPUT, OUTPUT, and ERROR (and you could
read those slots via EXTERNAL-PROCESS-INPUT-STREAM, etc.)

Your example doesn't involve "bash" or any other shell, so I'm
not sure what it would mean to "display the bash error string"
in that case.

If you really, really want to see a bash error string, there
are several ways of doing that.  One way:

? (run-program "/bin/bash" '("-c" "programDoesNotExist")
              :output :stream :error :output
              :wait nil)
#<EXTERNAL-PROCESS (/bin/bash -c programDoesNotExist)[10513] (RUNNING) #x302000FA698D>
? (external-process-output-stream *)
#<BASIC-CHARACTER-INPUT-STREAM UTF-8 (PIPE/5) #x302000FA65BD>
? (read-line *)
"/bin/bash: programDoesNotExist: command not found"
NIL

Kind of anticlimactic, isn't it ?

On Mon, 16 Apr 2012, clayton stanley 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.
>
> 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