[Openmcl-devel] where is shell output stored when launching an external program?
gb at clozure.com
Tue Apr 17 00:00:46 CDT 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
#<EXTERNAL-PROCESS (/bin/bash -c programDoesNotExist) (RUNNING) #x302000FA698D>
? (external-process-output-stream *)
#<BASIC-CHARACTER-INPUT-STREAM UTF-8 (PIPE/5) #x302000FA65BD>
? (read-line *)
"/bin/bash: programDoesNotExist: command not found"
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) (RUNNING) #x302000E6471D>
> ? *t*
> #<EXTERNAL-PROCESS (programDoesNotExist) (EXITED : 71) #x302000E6471D>
> ? (inspect *t*)
>  #<EXTERNAL-PROCESS (programDoesNotExist) (EXITED : 71) #x302000E6471D>
>  Type: EXTERNAL-PROCESS
>  Class: #<STRUCTURE-CLASS EXTERNAL-PROCESS>
>  PID: 919
>  %STATUS: :EXITED
>  %EXIT-CODE: 71
>  PTY: NIL
>  INPUT: NIL
>  OUTPUT: NIL
>  ERROR: NIL
>  STATUS-HOOK: NIL
>  PLIST: NIL
>  TOKEN: (0)
>  CORE: NIL
>  ARGS: ("programDoesNotExist")
>  SIGNAL: #<SEMAPHORE #x302000E6483D>
>  COMPLETED: #<SEMAPHORE #x302000E647BD>
>  WATCHED-FDS: NIL
>  WATCHED-STREAMS: NIL
>  EXTERNAL-FORMAT: #<EXTERNAL-FORMAT NIL/:UNIX #x30200049FE9D>
> 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.
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
More information about the Openmcl-devel