I'm trying to translate a typical UNIX command jmap -heap $(pgrep java)
to a command for the Ammonite-Shell.
My attempt so far: %'jmap("-heap", %'pgrep("java"))
.
I get the error SyntaxError: found "%'jmap(\"-heap\", %'pg", expected "while" |
... which seems to indicate the inner call to pgrep
was not actually translated as a command call and just passed in as a string.
In Ammonite, single
%
spawns a subprocess and prints out its result. In order to access command output you need to use%%
operator, which will returnCommandResult
object. This object containsout
field which is a stream of its output.You can nest it this way: