Mac: Perl script that will run when double-clicked

A

amirkarger

(This may be more a Mac question than a Perl question.)

When I double-click on a Perl script, it opens in TextEdit. Can I tell
Mac to run Perl scripts when they're double-clicked? The "Open With"
menu only lets me pick .apps, and perl isn't one.

It's hard to get good Google results with words like "mac double click
perl". Is there something simple like Windows' file types?

-Amir Karger
 
A

amirkarger

(This may be more aMacquestion than a Perl question.)

When I double-clickon a Perl script, it opens in TextEdit. Can I tellMacto run Perl scripts when they're double-clicked? The "Open With"
menu only lets me pick .apps, and perl isn't one.

It's hard to get good Google results with words like "macdoubleclick
perl". Is there something simple like Windows' file types?

-Amir Karger

Apologies for self-responding. At least a partial answer is, if you
save the program with .command suffix (with #!/usr/bin/perl in the
first line), then when you double click on the file, it'll open a new
terminal window and run.
Problems:

1) You need to chmod +x the script, or it won't run. Which sort of
defeats the purpose of creating a double-clickable program, doesn't
it?

2) Depending on your defaults for Terminal.app, the window might or
might not close when the script finishes.

-Amir
 
A

Anno Siegel

This seems to work only if I have no Terminal.apps open at the moment.
Or am I hallucinating?

Works for me in either situation (Terminal.app already running or not).

Anno
 
A

Anno Siegel

On Aug 22, 1:28 pm, (e-mail address removed) wrote:
1) You need to chmod +x the script, or it won't run. Which sort of
defeats the purpose of creating a double-clickable program, doesn't
it?

How so? What do you consider the purpose of making a perl script clickable?

Anno
 
A

amirkarger

How so? What do you consider the purpose of making a perl script clickable?

Anno

Good point.

The idea here is that I'm going to have downloadable files that the
user saves to their disk so they can click on it & run without ever
needing to open a Terminal themselves or type stuff on a command
line.

In case you're wondering about the purpose, I have a site called the
Scriptome which provides simple data munging tools for non-programming
biologists. To make things as super-simple as possible (no install or
config necessary), we originally set it up to have Perl one-liners you
cut & paste onto a command line, but people kept telling us that non-
programmers are afraid of the command line. I worked out a way to
make .pl's do the right thing when clicked on Windows, but wasn't sure
how we could handle it on Mac. If I actually knew how to build Mac
apps easily, I could do this in a fancier way (volunteers welcomed!).
But I'm really aiming for this stuff to just work; prettiness, bells &
whistles are optional. (Sorry for the plug, but you asked!)

-Amir
 
B

Ben Morrow

Quoth (e-mail address removed):
Good point.

The idea here is that I'm going to have downloadable files that the
user saves to their disk so they can click on it & run without ever
needing to open a Terminal themselves or type stuff on a command
line.

They don't... it's perfectly possible to chmod a file through the GUI.
In any case, this should be regarded as a security feature of MacOSX: the
point being that a user has to take affirmative action before a random
downloaded file can be executed (yes, I realise there are many ways
around this... still, it's worth something :) ).

Ben
 
A

amirkarger

Quoth (e-mail address removed):






They don't... it's perfectly possible to chmod a file through the GUI.
In any case, this should be regarded as a security feature of MacOSX: the
point being that a user has to take affirmative action before a random
downloaded file can be executed (yes, I realise there are many ways
around this... still, it's worth something :) ).

Ben

I probably should have taken this to a Mac group long ago. But as long
as I'm here ... I know you can chmod g/m/o +/- r/w in the GUI, but is
it truly possible to chmod +x? And if so, how? It's not an option in
the standard or advanced chmod GUI.

-Amir
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top