Women in Technology

Hear us Roar



Article:
  Using Python and AppleScript Together
Subject:   Doesn't work
Date:   2007-05-10 17:34:07
From:   bfr
Tried you ose example. Result: command not found. You must be leaving something out.
Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Noah Gift photo Doesn't work
    2007-05-12 15:55:55  Noah Gift | O'Reilly AuthorO'Reilly Blogger [View]

    My first guess would be the escaping somehow did not translate correctly for you. Try this:

    osascript -e 'tell app "Script Editor" to quit'

    If that works than you can break each piece of the command into a variable, test it by doing an echo $variable_name(name of your variable) one by one and then concatenate them together when you know the individual variables work.


    Another option would be to do this in python and just call a python script, which I in fact do quite a bit:

    An idea:

    import os

    ls = 'ls -l '
    dir = '/home'

    cmd = ls + dir

    def long_list():

    os.system(cmd)

    long_list()

    This type of format is a good way to wrap up shell command into python. Hope that helps!