Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

netytan

macrumors 6502
Original poster
May 23, 2004
254
0
I would like to open .py and .pl files with Python and Perl in the terminal by clicking them. I just cant figure out how. Can somone point me in the right direction here please.

Thanks,

Mark.
 
I'm not sure I understand the question. You want to open Terminal, run an "ls" command to get a list of files, and then run script files by clicking on them? I'm not sure this will work. You could maybe do it by selecing the filename, typing the name of the appropriate interpreter followed by a space, and pasting the script filename onto the command line, but unless the script filename is particularly unwieldy it would probably be faster to just type it.

I haven't yet made it to the MacOS X Missing Manual in my reading pile, but the typical Unix paradigm as you probably know is that you run scripts by typing the name at the command line, preceded by the name of the interpreter. An example would be "python deleteWindows.py".

You could probably run scripts in Finder by clicking them, though, because the Finder probably knows which program to associate with ".pl" scripts.

Maybe Apple added some magic I don't know about, though.


Crikey
 
Maybe he means that he wants to just double click the scripts from within the Finder, and have the terminal launch to run them? :confused: If that is indeed what you are after, netytan, then you could select the script in the finder, press OA - I, then in the section of the screen that says 'Open With', select Terminal. :eek:
 
Sorry, i thought it was pretty simple :eek:, what i want to do is to make Python and Perl scripts executable, ala Windows so that i dont have to go though the whole laungh terminal>cd>command thing just to test/run a simple program.

I considered writing a little app/droplet to do this but it seems like overkill, at the time, and i didnt know if it could be done otherwise.

I've tried what this before and you cant select to open any file type in terminal; nor can you drag the file to terminal.

Any ideas?

Mark.
 
Mac Help saves the day

Do a search in Mac Help for "Using command files with Terminal" (without the quotes). What you need to do is put the command to run the Perl/Python/whatever script into a command file, use chmod to make it executable, then double-click it to run whatever's inside - in this case, your script.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.