MacOS command line tool which executes OSA scripts (AppleScript, JavaScript, etc.)
Questions tagged [osascript]
267 questions
1
vote
1 answer
Applescript got "missing value"
I have the following applescript to add contacts from the command line
on run {firstName, lastName, workPhone, mobilePhone, workstreet, workzip, workcity, snr}
tell application "Contacts"
set theDate to current date
if theDate…

Felix de Courten
- 11
- 1
- 2
1
vote
1 answer
Errors when passing bash variable in osascript
Using osascript, I'm able to tell the Terminal application to open an ssh connection in a separate terminal window, however, I run into errors when trying to pass bash variables in the script.
This script works just fine:
osascript -e 'tell app…

jebrii
- 145
- 1
- 3
- 7
1
vote
1 answer
Cannot run program "osascript": error=2, No such file or directory
I am trying to run the following piece of applescript in a selenium test hosted on a remote grid.
protected void enableTouchIDLogin(){
Runtime runtime = Runtime.getRuntime();
String appleScriptCommand = "tell application \"System Events\" to…

es3735746
- 841
- 3
- 16
- 40
1
vote
1 answer
How to translate 'using terms from ...' to Javascript in an OSA Event Handler
I want to call some JavaScript code using the osascript command. The code should stay running until it receives a chat message from Messages. Ultimately, I intend to execute this from node and receive back the chat message, sender, etc.
I am able…

Harry
- 103
- 7
1
vote
1 answer
Trying to automate tabs and shell commands in Terminal?
I have a custom vim setup running inside split (GNU) screen sessions running in several tabs inside Terminal. Naturally I want to automate all that. So Ive Googled a lot and most answers talk about using osascript -e to run a bunch of AppleScript…

Eno
- 10,730
- 18
- 53
- 86
1
vote
1 answer
How to change terminal background to photo in OS X
In order to help differentiate between terminal windows from a 30k foot view, I'd like to have different background pics for my terminal windows.
Every time a terminal window opens, I'd like to set the background to a random pic from a certain…

jasonmclose
- 1,667
- 4
- 22
- 38
1
vote
2 answers
How to indent applescript when running in bash script?
osascript -e "set x to 3"
osascript -e "if x is 5 then"
osascript -e " tell application \"System Events\" to keystroke return"
osascript -e "end if"
The output i get
14:14: syntax error: Expected end of line but found end of script. (-2741)
0:6:…

bogen
- 9,954
- 9
- 50
- 89
1
vote
1 answer
use command `osascript -e 'quit app "Quicktime Player 7"'` with python
I am using osascript -e 'quit app "Quicktime Player 7"' in OSX Terminal to close the Quicktime Player 7 application, which works well, but can't get this same command working using python. What am I doing wrong?
This just runs, but does…

speedyrazor
- 3,127
- 7
- 33
- 51
1
vote
1 answer
Create bash script with osascript and passed var
I haven't really done much in the way of bash scripts before so any help would be appreciated!
I've added this function to my .bash_profile:
function test()
{
osascript -e 'tell app "System Events" to display dialog "$1"'
echo "my name is…

Rwd
- 34,180
- 6
- 64
- 78
1
vote
2 answers
Python passing file path variable into Applescript using osascript
I am trying to pass a file path into n Applescript from Python, not sure how to achieve it. The code below shows the working Applescript code which prompts to open a file, or files, then re-assigns the audio channels, saves and closes. Instead of…

speedyrazor
- 3,127
- 7
- 33
- 51
1
vote
1 answer
In OS X 10.9.2, command: osascript -e 'tell application "System Events" to keystroke "Honk" adds 'a' to end of all typed strings
Well, I mean, the title pretty much says it all. I'm using Python to pass
osascript -e 'tell application "System Events" to keystroke "Honk"'
to a 10.9 terminal. Using osascript to pass keystrokes to applications, and in 10.8 and below, this…

user2569302
- 11
- 1
- 5
1
vote
1 answer
Launching osascript from python and launchd
Here's the gist of my little program
One python script that checks if there is a new file (movie file) in a certain directory and update an sqlite3 database accordingly, thus queuing files to be processed. Running every minute with…

glitch
- 71
- 8
1
vote
0 answers
Call osascript through perl in OSX 10.9 doesn't work anymore
I'm writing an application for Mac (OSX, not iOS).
The installation runs a perl script which contains some "osascript" call, for example:
$res = qx(osascript -e 'launch application "MyApp"');
Or:
$res = qx(osascript -e 'tell application "System…

kande
- 559
- 1
- 10
- 28
1
vote
1 answer
Check whether there is an active application using osascript
I have a script that is run from an application (in my case macvim) that performs a certain command in an available Terminal window or opens a new window if terminal is not used
However, if the terminal is open and it has something running in window…

katzmopolitan
- 1,371
- 13
- 23
1
vote
2 answers
How do I pass a file path parameter to an osascript called from command line?
I am using a shell script which is calling these two lines of code:
iname=$(ls -d -1 $PWD/*jpg)
osascript -e 'tell app "Finder" to set desktop picture to POSIX file \"$iname\"'
where iname is a variable, which is the absolute path to the picture I…

user2407195
- 11
- 2