Running scripts in terminal

Discussion in 'Mac OS X 10.3 (Panther) Discussion' started by netytan, Aug 4, 2004.

  1. netytan macrumors 6502


    May 23, 2004
    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.


  2. Crikey macrumors 6502

    Jan 14, 2004
    Spencer's Butte, Oregon
    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".

    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.

  3. Billicus macrumors 6502a


    Apr 3, 2002
    Charles City, Iowa
    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:
  4. netytan thread starter macrumors 6502


    May 23, 2004
    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?

  5. wrldwzrd89 macrumors G5


    Jun 6, 2003
    Solon, OH
    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.

Share This Page