Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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:
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?#!/bin/sh cd `dirname $0` >/dev/null 2>&1 perl myscript.pl
Thanks in advance for your answers!
|
|---|