MacOS command line tool which executes OSA scripts (AppleScript, JavaScript, etc.)
Questions tagged [osascript]
267 questions
0
votes
1 answer
How to deal with white spaces in osascript
I'm in need of your assistance on how to deal with white space in a path.
In my example below, I'm setting some variables in a Terminal bash shell and executing, "osascript" from command line, utilizing these variables to run ['do shell script'] &…

walkerdan1
- 3
- 2
0
votes
2 answers
How can I do AppleScript's «event aevtrlgo» in JavaScript?
On macOS, the osascript command line tool can be used to run AppleScript and JavaScript, both of which have access to the Apple Events API.
For most of the API, the translation is quite straightforward. E.g.
tell application "Terminal" to…

Siguza
- 21,155
- 6
- 52
- 89
0
votes
0 answers
Script on iMac behaves differently when called from terminal versus from Raspberry pi
I have some scripts on my iMac (Yosemite) that work as I expect when called from the terminal but have different results when called from a Python 2.7 program on my Raspberry pi3.
Here is an example:
Script on the iMac - this script pauses iTunes;…

Gary
- 571
- 1
- 4
- 9
0
votes
1 answer
How do I get osascript/Applescript to accept command line parameters with SPACES in them?
If this code is called with CLP'S that have no spaces in them (such as "~ testing" or "/Volumes/BOOTCAMP testing") it runs fine. However, if the CLP's contain spaces (such as "/Volumes/Shared External testing", "~ test results" or "/Volumes/Shared…

Bryan Dunphy
- 799
- 1
- 10
- 22
0
votes
3 answers
how to interpret bash variables in applescript command
I am trying to write a bash script that reloads a given chrome tab, and I am passing the variable POSITION_STRING to applescript to dynamically determine the definition of the statement (as I thought thats what heredocs notations are used to…

user2167582
- 5,986
- 13
- 64
- 121
0
votes
0 answers
Open Terminal failed with osascript after electron-packager
When I try to execute an osascript command under my Electron project, it works under dev mode(1), but after building it with electron-packager(2) and executing the binary file, an error appears.
It works with this execution command to debug:
#…

Kevin Campion
- 2,223
- 2
- 23
- 29
0
votes
1 answer
Pass variable into AppleScript from python
Can someone show me how to pass a variable into an Applescript using osascript in python? I've seen some documentation/samples on doing this but I'm not understanding it at all.
Here is my python code:
# I want to pass this value into my apple…

LampShade
- 2,675
- 5
- 30
- 60
0
votes
4 answers
Rename Terminal Tabs Automatically with command
I am trying to rename opened terminal tabs in OSX, but I can only change the Terminal title with the code below. Is there a way to change the Tab title with command? I am using osascript with python 2.7.
name = """osascript -e 'tell application…

hzleonardo
- 463
- 1
- 7
- 16
0
votes
1 answer
Translating AppleScript if-clause to its JavaScript equivalent
I don't know if the issue lies with me or with OS X.
I have this AppleScript:
tell application "Caffeine"
if active then
turn off
else
turn on
end if
end tell
I translated this to this JavaScript
caffeine =…

hgiesel
- 5,430
- 2
- 29
- 56
0
votes
1 answer
Is the functionality of AppleScript (or OSA) a subset of Cocoa
i.e. Can I do everything I can do with OSA just as well with Cocoa? For example communicate with other open apps and tell them to do a specific thing (resize window, etc.)

hgiesel
- 5,430
- 2
- 29
- 56
0
votes
1 answer
Set a Timer for a function with multiple arguments
I have a collection of songs and I'd like to have them played in sequence.
If I run the function below, it will play milliseconds of each song but only the last one on the list in its entirety.
def play(*args):
for id_ in args:
print…

8-Bit Borges
- 9,643
- 29
- 101
- 198
0
votes
0 answers
Running osascript after 'su -'
I have a program run from the command line in OSX that I want to be able to pop up messages occasionally by running something like this:
osascript -e "display dialog \"Message\""
This works fine if I never change users. If I su other_user and run…

pythonic metaphor
- 10,296
- 18
- 68
- 110
0
votes
2 answers
LaunchAgent plist doesn't find path to AppleScript in iCloud
For some reason, Dropbox terminates (crashes or quits) after being online a few days, with no explanation.
I therefore started to research a way for AppleScript to automatically restart the application when it terminates.
That led me to this…

P A N
- 5,642
- 15
- 52
- 103
0
votes
1 answer
Running applescript or osascript in Sauce Remote grid
Similar issues without resolution: Run applescript using java on selenium webdriver(Grid) in sauce lab
I need to click to enable touchID on the Hardware dropdown menu on iPhone simulator with appleScript. I have the following piece of code that…

es3735746
- 841
- 3
- 16
- 40
0
votes
1 answer
Python osascript using extra quotation marks
Trying to use the following code (which works fine in applescript) to work in Python , fairly new to Python so I am not sure how I can get this string to work properly.
def getChromeSource():
cmdGetSource = """
osascript -e 'tell application…

bengerman
- 113
- 2
- 10