public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Example of run-process with redirection to pipe?
@ 2019-08-23 17:53 Sudarshan S Chawathe
  2019-08-24 11:01 ` spellcard199
  0 siblings, 1 reply; 5+ messages in thread
From: Sudarshan S Chawathe @ 2019-08-23 17:53 UTC (permalink / raw)
  To: kawa

I am probably missing something obvious but I cannot seem to figure out
how to use run-process with output redirected to a pipe.

Based on my reading of the manual, I have:

  (let ((p (run-process "echo Hello"
                        out-to: 'pipe)))
    (p:getInputStream))

but it give an error (full trace below) that I can't quite interpret:

  java.lang.IllegalAccessException: Class gnu.expr.PrimProcedure can not
  access a member of class java.lang.UNIXProcess with modifiers "public"

I would be grateful if someone could point me to some code illustrating
the use of the pipe feature of run-process. 

Regards,

-chaw

Stack trace:

w.scm:3:4: warning - no known slot 'getInputStream' in java.lang.Object
java.lang.IllegalAccessException: Class gnu.expr.PrimProcedure can not access a member of class java.lang.UNIXProcess with modifiers "public"
	at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:102)
	at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:296)
	at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:288)
	at java.lang.reflect.Method.invoke(Method.java:491)
	at gnu.expr.PrimProcedure.applyToConsumerX(PrimProcedure.java:310)
	at gnu.expr.PrimProcedure.applyToConsumer(PrimProcedure.java:189)
	at gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
	at gnu.mapping.CallContext.runUntilValue(CallContext.java:669)
	at gnu.mapping.Procedure.applyN(Procedure.java:136)
	at gnu.kawa.functions.NamedPart.applyN(NamedPart.java:90)
	at gnu.mapping.ProcedureN.applyToObject(ProcedureN.java:45)
	at gnu.mapping.Procedure.applyToConsumerDefault(Procedure.java:75)
	at gnu.kawa.functions.ApplyToArgs.applyToConsumerA2A(ApplyToArgs.java:132)
	at gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
	at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:343)
	at gnu.expr.CompiledModule.evalModule(CompiledModule.java:42)
	at gnu.expr.CompiledModule.evalModule(CompiledModule.java:60)
	at kawa.Shell.runFile(Shell.java:571)
	at kawa.Shell.runFileOrClass(Shell.java:474)
	at kawa.repl.processArgs(repl.java:710)
	at kawa.repl.main(repl.java:830)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Example of run-process with redirection to pipe?
  2019-08-23 17:53 Example of run-process with redirection to pipe? Sudarshan S Chawathe
@ 2019-08-24 11:01 ` spellcard199
  2019-08-25 18:46   ` Sudarshan S Chawathe
  0 siblings, 1 reply; 5+ messages in thread
From: spellcard199 @ 2019-08-24 11:01 UTC (permalink / raw)
  To: Sudarshan S Chawathe; +Cc: kawa

Hello. I am also new to kawa, and I don't know why it behaves the way it does (seems a java permissions thing to me), but you can get the InputStream using:

  (gnu.kawa.functions.RunProcess:getInputStreamFrom p)

I found this using "grep -r Stream" inside the Kawa/kawa/lib directory in the kawa source code, which I found to be a great learning resource.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, August 23, 2019 7:53 PM, Sudarshan S Chawathe <chaw@eip10.org> wrote:

> I am probably missing something obvious but I cannot seem to figure out
> how to use run-process with output redirected to a pipe.
>
> Based on my reading of the manual, I have:
>
> (let ((p (run-process "echo Hello"
> out-to: 'pipe)))
> (p:getInputStream))
>
> but it give an error (full trace below) that I can't quite interpret:
>
> java.lang.IllegalAccessException: Class gnu.expr.PrimProcedure can not
> access a member of class java.lang.UNIXProcess with modifiers "public"
>
> I would be grateful if someone could point me to some code illustrating
> the use of the pipe feature of run-process.
>
> Regards,
>
> -chaw
>
> Stack trace:
>
> w.scm:3:4: warning - no known slot 'getInputStream' in java.lang.Object
> java.lang.IllegalAccessException: Class gnu.expr.PrimProcedure can not access a member of class java.lang.UNIXProcess with modifiers "public"
> at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:102)
> at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:296)
> at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:288)
> at java.lang.reflect.Method.invoke(Method.java:491)
> at gnu.expr.PrimProcedure.applyToConsumerX(PrimProcedure.java:310)
> at gnu.expr.PrimProcedure.applyToConsumer(PrimProcedure.java:189)
> at gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
> at gnu.mapping.CallContext.runUntilValue(CallContext.java:669)
> at gnu.mapping.Procedure.applyN(Procedure.java:136)
> at gnu.kawa.functions.NamedPart.applyN(NamedPart.java:90)
> at gnu.mapping.ProcedureN.applyToObject(ProcedureN.java:45)
> at gnu.mapping.Procedure.applyToConsumerDefault(Procedure.java:75)
> at gnu.kawa.functions.ApplyToArgs.applyToConsumerA2A(ApplyToArgs.java:132)
> at gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
> at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:343)
> at gnu.expr.CompiledModule.evalModule(CompiledModule.java:42)
> at gnu.expr.CompiledModule.evalModule(CompiledModule.java:60)
> at kawa.Shell.runFile(Shell.java:571)
> at kawa.Shell.runFileOrClass(Shell.java:474)
> at kawa.repl.processArgs(repl.java:710)
> at kawa.repl.main(repl.java:830)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Example of run-process with redirection to pipe?
  2019-08-24 11:01 ` spellcard199
@ 2019-08-25 18:46   ` Sudarshan S Chawathe
  2019-08-30  0:04     ` Sudarshan S Chawathe
  2019-09-18 18:49     ` Per Bothner
  0 siblings, 2 replies; 5+ messages in thread
From: Sudarshan S Chawathe @ 2019-08-25 18:46 UTC (permalink / raw)
  To: spellcard199; +Cc: kawa

Thank you very much for the hint; it indeed works when invoked as you
write.

Regards,

-chaw

> Date: Sat, 24 Aug 2019 11:01:13 +0000
> From: spellcard199 <spellcard199@protonmail.com>
> Subject: Re: Example of run-process with redirection to pipe?
> 
> Hello. I am also new to kawa, and I don't know why it behaves the way it do=
> es (seems a java permissions thing to me), but you can get the InputStream =
> using:
> 
>   (gnu.kawa.functions.RunProcess:getInputStreamFrom p)
> 
> I found this using "grep -r Stream" inside the Kawa/kawa/lib directory in t=
> he kawa source code, which I found to be a great learning resource.
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Example of run-process with redirection to pipe?
  2019-08-25 18:46   ` Sudarshan S Chawathe
@ 2019-08-30  0:04     ` Sudarshan S Chawathe
  2019-09-18 18:49     ` Per Bothner
  1 sibling, 0 replies; 5+ messages in thread
From: Sudarshan S Chawathe @ 2019-08-30  0:04 UTC (permalink / raw)
  To: spellcard199; +Cc: kawa

Thank you very much for the hint; it indeed works when invoked as you
write.

Regards,

-chaw

> Date: Sat, 24 Aug 2019 11:01:13 +0000
> From: spellcard199 <spellcard199@protonmail.com>
> Subject: Re: Example of run-process with redirection to pipe?
> 
> Hello. I am also new to kawa, and I don't know why it behaves the way it do=
> es (seems a java permissions thing to me), but you can get the InputStream =
> using:
> 
>   (gnu.kawa.functions.RunProcess:getInputStreamFrom p)
> 
> I found this using "grep -r Stream" inside the Kawa/kawa/lib directory in t=
> he kawa source code, which I found to be a great learning resource.
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Example of run-process with redirection to pipe?
  2019-08-25 18:46   ` Sudarshan S Chawathe
  2019-08-30  0:04     ` Sudarshan S Chawathe
@ 2019-09-18 18:49     ` Per Bothner
  1 sibling, 0 replies; 5+ messages in thread
From: Per Bothner @ 2019-09-18 18:49 UTC (permalink / raw)
  To: Sudarshan S Chawathe; +Cc: kawa

I checked in a fix for this - the original test program now works.
This was somewhat tricky because the actual runtime-class UNIXProcess is non-public,
so reflection has to use the method from the parent class Process.  Which lead to to messy
complication relating to "syntheic bridge" methods.  Hope I got it right ...

A further improvement would be to do the method lookup at compile-time.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-08-30  0:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-23 17:53 Example of run-process with redirection to pipe? Sudarshan S Chawathe
2019-08-24 11:01 ` spellcard199
2019-08-25 18:46   ` Sudarshan S Chawathe
2019-08-30  0:04     ` Sudarshan S Chawathe
2019-09-18 18:49     ` Per Bothner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).