Hello,

As I've heard, on MacOSX one can write a shell script, give it an extension ".command", and once its clicked on in Finder, the script runs with /bin/sh ?
Does anybody know - can I put sheebang line into such script pointing to Perl interpreter - will it be executed using Perl interpreter or Finder is hardcoded to execute all .command files via /bin/sh? And what is the path to perl on MacOSX - /usr/bin/perl ?

Why I'm asking: I'm struggling with a problem - I have a perl script. I wish to give user ability to invoke it somehow on macosx. I've tried writing "foo.command" file and placing it into the directory where that script resides, with content like this:

#!/bin/sh cd `dirname $0` >/dev/null 2>&1 perl myscript.pl
but $0 appears to be ALWAYS UNDEFINED on MacOSX!! ANd all .command files are being executed with current directory set to user's home directory, so I see NO way of determining the directory to change to in order to be able to execute that perl script. That's why I'm searching for a user-friendly way of executing of a perl script from finder by just doubleclicking on it (so it would work on any macosx-running computer).. Do you have any suggestions?

Thanks in advance for your answers!


In reply to Can files with extension ".command" on MacOSX be perl scripts? What is a way to let users execute Perl scripts on macosx from Finder? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.