Hi:
I'm trying to start some processes and connect them using pipes with ABCL (like Unix shell pipes). I've reviewed the documentation but I haven't found anything. Are I missing something? If not, are there any plans of adding input, output and error parameters for run-program (like SBCL, CCL, etc.)?
Greets and thanks in advance. Rafael J. Alcántara Pérez.
Hi Rafael,
On Mon, May 12, 2014 at 11:20 PM, Sistemas sistemas@dedaloingenieros.comwrote:
Hi:
I'm trying to start some processes and connect them using pipes with ABCL (like Unix shell pipes). I've reviewed the documentation but I haven't found anything. Are I missing something? If not, are there any plans of adding input, output and error parameters for run-program (like SBCL, CCL, etc.)?
There's a function like that in run-program.lisp:
(defun run-program (program args &key environment (wait t) clear-environment) "Run PROGRAM with ARGS in with ENVIRONMENT variables.
Possibly WAIT for subprocess to exit.
Optionally CLEAR-ENVIRONMENT of the subprocess of any non specified values.
Creates a new process running the the PROGRAM.
ARGS are a list of strings to be passed to the program as arguments.
For no arguments, use nil which means that just the name of the program is passed as arg 0.
Returns a process structure containing the JAVA-OBJECT wrapped Process object, and the PROCESS-INPUT, PROCESS-OUTPUT, and PROCESS-ERROR streams.
c.f. http://download.oracle.com/javase/6/docs/api/java/lang/Process.html
Notes about Unix environments (as in the :environment):
* The ABCL implementation of run-program, like SBCL, Perl and many other programs, copies the Unix environment by default.
* Running Unix programs from a setuid process, or in any other situation where the Unix environment is under the control of someone else, is a mother lode of security problems. If you are contemplating doing this, read about it first. (The Perl community has a lot of good documentation about this and other security issues in script-like programs.
The &key arguments have the following meanings:
:environment An alist of STRINGs (name . value) describing new environment values that replace existing ones.
:clear-env If non-NIL, the current environment is cleared before the values supplied by :environment are inserted.
:wait If non-NIL, which is the default, wait until the created process finishes. If NIL, continue running Lisp until the program finishes. "
Does that solve your problem?
Hi Rafael,
On Tue, May 13, 2014 at 8:56 PM, Erik Huelsmann ehuels@gmail.com wrote:
Hi Rafael,
On Mon, May 12, 2014 at 11:20 PM, Sistemas sistemas@dedaloingenieros.comwrote:
Hi:
I'm trying to start some processes and connect them using pipes with ABCL (like Unix shell pipes). I've reviewed the documentation but I haven't found anything. Are I missing something? If not, are there any plans of adding input, output and error parameters for run-program (like SBCL, CCL, etc.)?
There's a function like that in run-program.lisp:
[ snip ]
This makes me discover RUN-PROGRAM:
CL-USER(1): (apropos 'run-program) SYSTEM:RUN-PROGRAM (fbound) RUN-PROGRAM
The following returns the required documentation for me:
CL-USER(2): (documentation #'system:run-program 'function) "<text I pasted for you before>"
Hope that helps you consult the docs!
El Martes, 13 de mayo de 2014 21:02:18 Erik Huelsmann escribió:
Hi Rafael,
On Tue, May 13, 2014 at 8:56 PM, Erik Huelsmann ehuels@gmail.com wrote:
Hi Rafael,
On Mon, May 12, 2014 at 11:20 PM, Sistemas sistemas@dedaloingenieros.comwrote:
Hi:
I'm trying to start some processes and connect them using pipes with ABCL (like Unix shell pipes). I've reviewed the documentation but I haven't found anything. Are I missing something? If not, are there any plans of adding input, output and error parameters for run-program (like SBCL, CCL, etc.)?
There's a function like that in run-program.lisp:
[ snip ]
This makes me discover RUN-PROGRAM:
CL-USER(1): (apropos 'run-program) SYSTEM:RUN-PROGRAM (fbound) RUN-PROGRAM
The following returns the required documentation for me:
CL-USER(2): (documentation #'system:run-program 'function) "<text I pasted for you before>"
Hope that helps you consult the docs!
Hi Erik:
Thankyou, I've seen the documentation before sending my original mail :) I tryed to make a simple pipe with this piece of code:
(let ((p1 (system:run-program "echo" '("zero") :wait nil)) (p2 (system:run-program "grep" '("zero") :wait nil))) (setf (system:process-input p2) (system:process-output p1)) (system:process-wait p1) (system:process-wait p2))
It hangs, so I don't know if I am missing something.
Thanks again :) Rafael J. Alcántara Pérez.
On 13 May 2014, at 22:40, Sistemas sistemas@dedaloingenieros.com wrote:
Thankyou, I've seen the documentation before sending my original mail :) I tryed to make a simple pipe with this piece of code:
(let ((p1 (system:run-program "echo" '("zero") :wait nil)) (p2 (system:run-program "grep" '("zero") :wait nil))) (setf (system:process-input p2) (system:process-output p1)) (system:process-wait p1) (system:process-wait p2))
Unfortunately, I don’t think that the ABCL API currently supports such redirection although the docs misleadingly imply that such a thing should be possible . ABCL 1.x is implemented to the Java 5 JVM API, for which the underlying [ProcessBuilder][1] object does not support input/output output stream redirection. The [Java 7 API][process-builder-java7] supports such redirection, so you could implement the necessary abstractions using either the low-level Java Function Interface or the higher-level JSS contrib as long as your target runtime platform was Java 7 or better.
In general, the ABCL implementation could use a strategy for supporting such useful primitives when they are available in the underlying platform.
Out of curiosity, is anybody actually running ABCL on Java 5 at the moment? Oracle has designated Java 5 as obsolete at this point, but it is probably still in use in legacy enterprise situations where migration is not possible for one reason or another. In my opinion, if we were to make a leap, I would probably skip Java 6, and go straight to Java 7, as there is much greater gain for the pain in the subjective terms of useful APIs.
[1]: http://docs.oracle.com/javase/6/docs/api/java/lang/ProcessBuilder.html [process-builder-java7]: http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html
On May 14, 2014, at 10:24, Mark Evenson evenson@panix.com wrote: [...]
Out of curiosity, is anybody actually running ABCL on Java 5 at the moment? Oracle has designated Java 5 as obsolete at this point, but it is probably still in use in legacy enterprise situations where migration is not possible for one reason or another. In my opinion, if we were to make a leap, I would probably skip Java 6, and go straight to Java 7, as there is much greater gain for the pain in the subjective terms of useful APIs.
The usual pattern seems to be to keep an old stable version available for download for users on older platforms.
Rudi
El Miércoles, 14 de mayo de 2014 10:24:51 Mark Evenson escribió:
On 13 May 2014, at 22:40, Sistemas sistemas@dedaloingenieros.com wrote: : Unfortunately, I don’t think that the ABCL API currently supports such redirection although the docs misleadingly imply that such a thing should be possible . ABCL 1.x is implemented to the Java 5 JVM API, for which the underlying [ProcessBuilder][1] object does not support input/output output stream redirection. The [Java 7 API][process-builder-java7] supports such redirection, so you could implement the necessary abstractions using either the low-level Java Function Interface or the higher-level JSS contrib as long as your target runtime platform was Java 7 or better.
In general, the ABCL implementation could use a strategy for supporting such useful primitives when they are available in the underlying platform.
Finally I've solved the problem using threads [3] (from bordeaux-threads) :)
BTW, now I have a problem when using CL+SSL that seems the ticket 355 [1] and 251 [2]. I'll be waiting for good news about that issues :)
Greets and thanks again. Rafael J. Alcántara Pérez.
[1]http.//abcl.org/trac/ticket/355 [2]http://abcl.org/trac/ticket/251 [3]http://pastebin.com/exbrTKxM%5B1]
On 19 May 2014, at 09:44, Administrador Sistemas sistemas@dedaloingenieros.com wrote:
El Miércoles, 14 de mayo de 2014 10:24:51 Mark Evenson escribió:
On 13 May 2014, at 22:40, Sistemas sistemas@dedaloingenieros.com wrote:
BTW, now I have a problem when using CL+SSL that seems the ticket 355 [1] and 251 [2]. I'll be waiting for good news about that issues :)
Greets and thanks again. Rafael J. Alcántara Pérez.
[1]http.//abcl.org/trac/ticket/355 [2]http://abcl.org/trac/ticket/251 [3]http://pastebin.com/exbrTKxM
CL+SSL is now working with a series of [patches to CFFI][1], which are in the process of being revised for submission in an upcoming CFFI Quicklisp release.
Things work well enough that
CL-USER> (require :abcl-contrib)(require :quicklisp-abcl)(ql:quickload :drakma)(drakma:http-request “https://google.com%E2%80%9D)
“works” (it hangs on the first request, but subsequent requests go through: just retry when you hit the first restart).
[1]: https://github.com/cffi/cffi/pull/43
armedbear-devel@common-lisp.net