Terminal command to bring up shutdown dialog? [duplicate]

You can send loginwindow the kAEShowShutdownDialog Apple event:

osascript -e 'tell application "loginwindow" to «event aevtrsdn»'

The four letter codes for Apple events are listed in AERegistry.h. See this answer for more information.


This should work:

Applescript:

-- Open  Shut Down Dialog...
-- Save this text as file named shutdown.scpt
tell application "System Events"
    set uiScript to click menu bar item "Apple" of menu bar 1 of application process "Finder"
    set uiScript to click menu item "Shut Down…" of menu 1 of menu bar item "Apple" of menu bar 1 of application process "Finder"
end tell

You can run it from Terminal like:

osascript shutdown.scpt