Thanks, Alex, for pointing out the the ‘make’ word, which is something new to
me.
I will study the example usages that you listed.
————
I realize that I did not make my original intention clear enough.
Here is what I want to do in factor:
(1) invoke custom command in shell: cmd1 -a A -b B
The result is printed out to stdout.
(2) Take the output of (1) and select (or manipulate) the lines
And print them to stdout
(3) invoke another custom command: cmd2 -c C…
So, in factor, from what I leaned so far, to accomplish the above I can do
{ “cmd1 -a A -b B” [ quot ] “cmd2 -c C” } run-pipeline
My original issue was to construct the string “cmd1 -a A -b B” and “cmd2 -c C”
in a flexible way so that I can choose to supply (or not supply) those argument
A, B, C.
And find a clean way to put everything together into { … } for run-pipeline.
By the way,
Your suggestion in another email of implementing >process looks interesting to
explore.
Any example usage in this case ?
Thanks
HP
> On Sep 22, 2015, at 12:23 PM, Alex Vondrak <ajvond...@gmail.com> wrote:
>
> Ultimately, I may also insert some factor quot in betweeen
> str1 and str2 to do some processing before handing the
> result to cmd2.
>
> Do you mean you want to take the output of running cmd1, manipulate it, then
> pass *that* to cmd2? Because that sounds rather different from what your
> example code looks like it's actually trying to do.
>
> It seems like your example is trying to construct launch descriptors
> independently, then pass those entire results to run-pipeline at once. Which
> is altogether easier: if I understand right, you're basically there already,
> but your main concern is more about how to build the array in a prettier way?
> If that's it, I suggest the `make` vocabulary:
> http://docs.factorcode.org/content/article-namespaces-make.html
> <http://docs.factorcode.org/content/article-namespaces-make.html>
>
> Some examples of `make` usage in the wild:
> https://github.com/slavapestov/factor/blob/master/basis/io/backend/unix/unix-tests.factor#L142-L147
>
> <https://github.com/slavapestov/factor/blob/master/basis/io/backend/unix/unix-tests.factor#L142-L147>
> https://github.com/slavapestov/factor/blob/master/basis/bootstrap/image/upload/upload.factor#L47-L51
>
> <https://github.com/slavapestov/factor/blob/master/basis/bootstrap/image/upload/upload.factor#L47-L51>
> https://github.com/slavapestov/factor/blob/master/extra/graphviz/render/render.factor#L62-L67
>
> <https://github.com/slavapestov/factor/blob/master/extra/graphviz/render/render.factor#L62-L67>
>
> Granted, all of those are building a single process, not a pipeline. But the
> same principles apply:
>
> : cmd1 ( -- ) ... ;
> : cmd2 ( -- ) ... ;
>
> [ cmd1 , cmd2 , ] { } make run-pipeline
>
> On Mon, Sep 21, 2015 at 9:21 PM, HP Wei <hpwe...@gmail.com
> <mailto:hpwe...@gmail.com>> wrote:
> I want to run binary codes (C++) under linux using run-pipeline
>
> In linux shell, the task is
>
> cmd1 -a arg1 -b arg2 | cmd2 -c arg3
>
> I know in general, in factor, I need to construct
>
> { str1 str2 } run-pipeline
> where str1 = “cmd1 -a arg1 -b arg2”
> str2 = “cmd2 -c arg3”
> Ultimately, I may also insert some factor quot in betweeen
> str1 and str2 to do some processing before handing the
> result to cmd2.
>
>
> Here is what I envision:
>
> TUPLE: cmd1 a b ;
>
> : <cmd1> ( — cmd1 )
> cmd1 new
> “default a” >>a
> “default b” >>b ;
>
> : get-cmd1 ( cmd1 — str1 )
> [ a>> ] [ b>> ] bi
> “cmd1 -a %s -b %s” sprintf ;
>
> so now, I can write
>
> <cmd1>
> my_b >>b
> get-cmd1
>
> ————— similarly for cmd2.
>
> But I bump into a mental block when trying to
> put things together for run-pipeline
>
> If there were just one cmd1 (without cmd2),
> I thought I could do
>
> ${ <cmd1> my_b >>b get-cmd1 } run-pipeline
>
> Adding cmd2, I could write
>
> ${ <cmd1> my_b >>b get-cmd1 <cmd2> my_c >>c get-cmd2 } run-pipeline
>
> But this looks ugly.
> Is there a simpler way ?
>
> Thanks
> HP Wei
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net <mailto:Factor-talk@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/factor-talk
> <https://lists.sourceforge.net/lists/listinfo/factor-talk>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk