For what it's worth, you can make this into an executable script by
putting a shebang line in front of it (and marking the resulting
script file executable with chmod +x).  The script file would need to
be in a directory on your $PATH.

For example:

#!/Users/rauldmiller/j901/bin/jconsole
NB. ...
row =: cut&> ''"_^:('#'={.)each (cutLF;.1~'Host 'E.])fread'~/.ssh/config'
...

(Except, of  course, your copy of J is almost certainly not in a
directory named 'rauldmiller'... It's a bit inconvenient that
different installations of J are in different directory, but maybe we
can get away with calling this a security feature, or some such...)

This works in unix/linux because unix operating system implementations
look at the beginning of an executable file to determine how to handle
it, and because #! as the first two characters means it's a script
file, with the script interpreter coming next on that line.

This works in J because the names are undefined, so the whole first
line becomes a verb train, which is valid syntax. (Other scripting
languages either make # be a comment-to-end-of-line character, or by
having special handling for a first line which begins with #! --
neither seem to have been necessary for J.)

Also fun, in this context, is a line reading:

echo ARGV

Thanks,

-- 
Raul

On Thu, Aug 8, 2019 at 11:53 AM Alex Shroyer <[email protected]> wrote:
>
> Thanks Jim for pointing out NuVoc. It really is well done, and as I have
> been (and am still) learning J it's usually my first choice for grasping a
> new concept or when I need a quick refresher.
> The more "reference style" stuff in jsoftward.com/help is also invaluable
> (as I type this I realize I had a tab open to
> https://www.jsoftware.com/help/phrases/locate_select.htm from last week).
>
> I'll also echo what Raul said, you can learn at your own pace and just
> because you're a beginner doesn't mean that the problems you're solving
> with J or the software you write with it isn't also valuable.
> There are surely many more people who are not experts in J than there are
> experts.  I'm certainly not an expert but I feel like it's a good tool and
> I often use it just as a desktop calculator or as a replacement for
> Perl/Ruby/Python for throwaway Linux scripting jobs.  J is powerful and
> elegant, but it's not like a classic sports car that has to be carefully
> kept under wraps most of the time, and only brought out on special
> occasions for showing off.
>
> In the spirit of showing off non-expert-level J work, here is one of mine.
> It's not as elegant as I would like it to be, but it did the job I wanted
> it to do at the time:
>
> NB. put J on $PATH, then call this script as:
> NB. j ssh-config-table.ijs
> NB. it reads ~/.ssh/config and displays it in table form, even if some of
> the Host entries don't have all the same fields
> NB. or if they are in different order than each other.
> NB. note that it DOES NOT work if you use the ssh_config file rules of
> wildcard or multiple hosts per ruleset, rather each
> NB. host must use its own set of rules.  Maybe someday someday it will
> parse the ssh_config file correctly
> NB. but for now it "works on my machine"
>
> row =: cut&> ''"_^:('#'={.)each (cutLF;.1~'Host 'E.])fread'~/.ssh/config'
> key =: a:-.~~.,{."1 row
> val =: {:"1 row
> idx =: {."1 key i.row
> echo key,/:~3 :'(y{val) (y{idx) } a:#~1+#key'"0 i.#val
> exit''  NB. comment out this line do debug
>
>
>
> The J community benefits from hearing from folks at all points in the
> spectrum between beginner and master, so thank you for saying hi.
>
> Regards,
> Alex
>
>
> On Thu, Aug 8, 2019 at 11:21 AM Raul Miller <[email protected]> wrote:
>
> > On Wed, Aug 7, 2019 at 7:31 PM 'Jim Russell' via General
> > <[email protected]> wrote:
> > > Pity there are so few of you bright enough to become proficient, and so
> > many of us that feel we shouldn’t use it unless we use it well. Sigh...
> >
> > I think it's mostly a matter of pacing.
> >
> > Kids pick up J at the community college level without any unusual
> > stress or anything (and quite a bit of it can fit in at the grade
> > school level, assuming enough comfort with concepts like "numbers" and
> > "letters").  But, not all in one day.
> >
> > Anyways, ... people shy away from the oddest things, sometimes. (And,
> > I guess, there will always have been people who did the discouraging
> > "you don't know *that*? hahahah" thing...)
> >
> > But having small projects to use it in can also help. Frivolous
> > projects are great for this kind of thing.
> >
> > Thanks,
> >
> > --
> > Raul
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to