Helpful suggestions! I'll work on them, and let you know what works for me.
Thanks kindly, all ~cw


On Mon, Oct 21, 2013 at 10:03 AM, John Benediktsson <mrj...@gmail.com>wrote:

> These are all great suggestions, when you get it working, it would be
> great if you'd contribute it!
>
> Best,
> John.
>
>
> On Mon, Oct 21, 2013 at 8:54 AM, Alex Vondrak <ajvond...@gmail.com> wrote:
>
>> Maybe this whole thing is solved by going directly to the stream solution?
>>
>> $ rlwrap ./factor -run=listener 2> /dev/null
>> IN: scratchpad USING: io.encodings.utf8 io.launcher ;
>> IN: scratchpad "find /home/alex/talks/factor -name *.pdf" utf8 [ lines
>> ] with-process-reader .
>> {
>>     "/home/alex/talks/factor/factor.pdf"
>>     "/home/alex/talks/factor/factor-test.pdf"
>> }
>> IN: scratchpad "find /home/alex/talks/factor -name DOESNOTEXIST" utf8
>> [ lines ] with-process-reader .
>> { }
>> IN: scratchpad "find /proc -name PERMISSION_DENIED_ERROR" utf8 [ lines
>> ] with-process-reader .
>> Process exited with error code 1
>>
>> Launch descriptor:
>>
>> T{ process
>>     { command
>>         "find /proc -name PERMISSION_DENIED_ERROR"
>>     }
>>     { environment H{ } }
>>     { environment-mode +append-environment+ }
>>     { stdout T{ fd { disposed t } { fd 19 } } }
>>     { group +same-group+ }
>>     { status 1 }
>>     { pipe
>>         T{ pipe
>>             { in T{ fd { disposed t } { fd 18 } } }
>>             { out T{ fd { disposed t } { fd 19 } } }
>>         }
>>     }
>> }
>>
>> Type :help for debugging help.
>>
>> See
>> -
>> http://docs.factorcode.org/content/word-with-process-reader%2Cio.launcher.html
>> - http://docs.factorcode.org/content/word-lines,io.html
>> - General perusal of
>> http://docs.factorcode.org/content/article-io.launcher.html and
>> http://docs.factorcode.org/content/vocab-io.launcher.html
>>
>> As for the original problem of I/O redirection, there seem to be some
>> docs on that at
>> http://docs.factorcode.org/content/article-io.launcher.redirection.html
>> and some examples in
>> http://docs.factorcode.org/content/article-io.launcher.examples.html
>>
>> Hope that helps,
>> --Alex Vondrak
>>
>> On Mon, Oct 21, 2013 at 2:26 AM, Björn Lindqvist <bjou...@gmail.com>
>> wrote:
>> > 2013/10/21 CW Alston <cwalsto...@gmail.com>:
>> >> :: <mdfind-request> ( filename -- seq )
>> >>          "'kMDItemFSName == " filename tri-quotes-surround append  "'"
>> >> append ;
>> >>
>> >> : <mdfind-process> ( filename -- process )
>> >>      <mdfind-request>        ! ( -- seq )
>> >>  '[ "mdfind" , "-onlyin" , "/" , _ , ">" ,
>> >> "/Users/cwalston/factor/mdfind.txt" , ]
>> >>  { } make      ! ( -- seq )
>> >>       <process> swap >>command
>> >>       t >>detached clone  ! ( -- process )
>> >> ;
>> >>
>> >> And then, "Finding Joy in Combinators.pdf" <mdfind-process> contains a
>> >> command
>> >> sequence that looks like this:
>> >> {
>> >>     "mdfind"
>> >>     "-onlyin"
>> >>     "/"
>> >>     "'kMDItemFSName == \"Finding Joy in Combinators.pdf\"'"
>> >>     ">"
>> >>     "/Users/cwalston/factor/mdfind.txt"
>> >> }
>> >
>> > The command>> attribute in <process> should be a string not a sequence
>> > of strings. I think that is the core of your problem, not sure. Also,
>> > input and output redirection is a feature of the shell, not the os, so
>> > you need to wrap those commands in a subshell. But that is platform
>> > dependent since not all shells are available everywhere and they dont
>> > all have the same features. Here is how you could write a find utility
>> > for Windows (using gnu find), maybe you can use it as a template:
>> >
>> > USING: formatting io.launcher kernel ;
>> > IN: cmdpipe
>> >
>> > CONSTANT: find-bin "C:\\Program Files (x86)\\Git\\bin\\find.exe"
>> >
>> > : shell-command ( str -- str' )
>> >     "cmd /C \"%s\"" sprintf ;
>> >
>> > : find-command ( dir pattern out-path -- str )
>> >     [ find-bin ] 3dip "\"%s\" \"%s\" -name \"%s\" > \"%s\"" sprintf ;
>> >
>> > : run-find ( dir pattern out-path -- proc )
>> >     find-command shell-command run-process ;
>> >
>> > IN: scratchpad "C:\\Users\\bjourne\\Downloads" "*.pdf"
>> > "C:\\Users\\bjourne\\result.txt" run-find
>> >
>> >
>> > --
>> > mvh/best regards Björn Lindqvist
>> >
>> >
>> ------------------------------------------------------------------------------
>> > October Webinars: Code for Performance
>> > Free Intel webinars can help you accelerate application performance.
>> > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the
>> most from
>> > the latest Intel processors and coprocessors. See abstracts and
>> register >
>> >
>> http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
>> > _______________________________________________
>> > Factor-talk mailing list
>> > Factor-talk@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>>
>> ------------------------------------------------------------------------------
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
>> from
>> the latest Intel processors and coprocessors. See abstracts and register >
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>


-- 
*~ Memento Amori*
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to