MacOS command line tool which executes OSA scripts (AppleScript, JavaScript, etc.)
Questions tagged [osascript]
267 questions
0
votes
1 answer
Python tempfile.mkstemp(): AttributeError: 'function' object has no attribute 'mkstemp'
Not my code, I was trying a tool that includes the osascript library.
In the lib, at the line path = temp.tempfile() the error in the title is raised.
The temp library, correctly imported by the authors, has the following code itself:
f, path =…

Joe Valeriana
- 610
- 7
- 11
0
votes
1 answer
Get process id after spawning new application via applescript(osascript) using tell
tell application "Google Chrome"
make new window
open location "https://google.com"
end tell
The above command spawns up an instance of google chrome. I want to get the process id of this process so that I can kill it later. Please note that I am…

knowbalpreet
- 38
- 4
0
votes
1 answer
AppleScript generates an unknown error which is not listed in the reference table
I get this error:
test.scpt: script error -41. Couldn't get error text because of error -1700.
AppleScript contents:
tell application "Adobe Photoshop CC 2019"
activate
set js to "#include '/Users/temp_myname/My Application/tmp/Adobe…

extremecoder85
- 119
- 1
- 12
0
votes
1 answer
Progress Bar in Applescript window
I want to download different apps with a bash script on macOS.
As there are some larger downloads (e.g. Office 365) I would like to include a progress bar in a regular macOS Window.
The applications download+install script looks like this
cd…

LWun
- 71
- 1
- 11
0
votes
1 answer
Osascript "text returned of" input does not include whitespace
I have the following script for creating a new user on macOS:
#!/bin/bash
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
consoleUser() {
echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3…

LWun
- 71
- 1
- 11
0
votes
1 answer
App build failed in xcode with Continuing in background (Failed to display Xcode notification) due to the sentry
Unable to build my app suddenly. This is the error which I got after running the caused by: script error: osascript: no such component "JavaScript".
Continuing in background.
Error: Failed to display Xcode notification
caused by:…

sejn
- 2,040
- 6
- 28
- 82
0
votes
0 answers
Calling osascript from python
I'm a beginner programmer and have been writing a few very simple scripts in python to automate opening up a few apps and chrome tabs for a workflow session. Apologies if my question is very simple but have been looking everywhere for an answer,…

Jonny Studholme
- 1
- 1
0
votes
2 answers
How can I detect a button press reported by osascript in a calling shell?
I'm currently working on a script to notify a user when their password will expire. The prompt appears, but no matter what button I press, it results to the same outcome, "Change Later was chosen". Any ideas?
#!/bin/bash
button=$(osascript -e 'tell…

WorkingOnIt
- 1
- 2
0
votes
1 answer
osascript changing wallpaper with variable containing the path fails
I'm trying to run this script to change my wallpaper but I'm running into issues when the path for the file is in a variable
sh run.sh
wallpaper_path="$(pwd)/assets/wallpaper.jpg"
osascript -e 'tell application "Finder" to set desktop picture to…

Stupid.Fat.Cat
- 10,755
- 23
- 83
- 144
0
votes
1 answer
How to properly pass nested lists from Applescript to Bash
I'm working on a project that involves using Applescript to make a list of open URLs within the users Google Chrome Browser, in order to save them for when I eventually want to re-open Chrome. Finding that I needed to have a way to determine which…
0
votes
1 answer
Opening updated version of bash with osascript
I have the below osascript in bash.
This has worked fine for me for quite some time however recently I used HomeBrew to upgrade my version of bash on my Apple machine from 3.x to 5.x. This works fine in all cases (except osascript) such as clicking…

user5429087
- 139
- 2
- 10
0
votes
1 answer
applescript - conditional statement is syntax error only if evaluates to false
Struggling with this bit too long, trying my luck here.
I'm running a simple task with applescript which is wrapped inside condition:
If application iTerm2 is running.
If the iterm2 is running, then everything is fine and the execution is successful…

Daniel Krom
- 9,751
- 3
- 43
- 44
0
votes
1 answer
Error: No result was returned from some part of this expression. (-2763)
Getting the following error when running my Applescript:
348:532: execution error: No result was returned from some part of this expression. (-2763)
The applescript runs successfully when utilized within a python script and there are no issues. But…

Zak44
- 341
- 1
- 5
- 24
0
votes
1 answer
AppleScript forward error number to osascript as exit status
I am trying to throw a specific error code inside of a applescript snippet that I am running via osascript.
This is my code:
osascript -e "if ((clipboard info) as string) does not contain \"«class PNGf»\" then" -e "error number 61" -e "end…

Marcel
- 1,509
- 1
- 17
- 39
0
votes
1 answer
Osascript not executing - returns empty array
I have an exec() command on my code which runs an applescript from the desktop
$cmd = "osascript /Users/***/Desktop/script.app";
exec($cmd, $output);
print_r($output);
On one computer it runs without errors, on the second computer it returns…

Spy
- 153
- 10