0

I set "Apple > Preferences > CDs and DVDs > When you insert a video DVD" to run my script written in AppleScript or JavaScript. My script for testing this calls a shell command to eject the DVD: drutil eject

//JXA version
var app = Application.currentApplication()
app.includeStandardAdditions = true
delay(2) // even a delay of 5 minutes does not fix problem
app.doShellScript("drutil eject")
app.say("Finished")

This script is successfully called every time I insert a DVD but it might eject the DVD the first or second time. After that it never ejects the DVD again. I can unplug and replug the drive, add long delays and edit and change scripts but nothing helped. I can go to a terminal window and call the same command "drutil eject" and from here it ejects the DVD every time, but not from within the script.

I finally found a workaround for automating:

var dvd = Application('DVD Player')
dvd.ejectDvd()
dvd.quit()

Calling the DVD Player to eject the DVD has so far worked every time.

Any ideas why the shell command when called from the terminal works every time but from the Apple script of a Python script called from the Apple script fails every time except for maybe the first time?

Buoy
  • 795
  • 1
  • 8
  • 13
  • Try using the full path... `app.doShellScript("/usr/bin/drutil eject")` – Mark Setchell Nov 29 '16 at 20:50
  • Okay, I added the full path and tried it several different ways with long delays, etc., but the DVD still did not eject from within the script. – Buoy Nov 29 '16 at 21:31

0 Answers0