How can a remotely launched Applecsript display dialog?

I have many Mac-computers running a variety of Mac OS X systems, including Tiger, Leopard, and Snow Leopard. On Tiger and Leopard, a Terminal bash-script could launch a compiled and saved Applescript (in /Applications/myLogout.app), which uses "say" to tell the user the system is going down in two-minutes. It then waits (delay 120), and then uses "say" again with this message, "System going down in 10 seconds". That's followed by a "display dialog" with the same message. The User could "Cancel" to stop the execution of the Applescript. If not, the applicaton proceeds to do cleanup work, like eliminating pesky /var/tmp files that invariablely end up as "Recovered" files or folders, and then it does "shut down".
I could remote login from another computer and execute this simple bash-script:
    #!/bin/bash
    if [ -x "/Applications/myLogout.app" ] ; then
       osascript /Applications/myLogout.app display >/dev/null 2>&1"
    else
       echo "Can't find Logout application"
    fi
    exit 0
This bash-script would wait at the osascript command until the Applescript terminated, which it did either because someone clicked Cancel in the dialog, or the "shut down" command occurred. My session then regained control, and usually was quickly terminated as a remote session.
But now, Snow Leopard wouldn't properly execute the Applescript. It always fails for lack of a WindowServer connection to my remote session.
I can't use launchd for this because of similar restrictions. For one thing, I have no clue who might be the active user on the target computer, and never had to worry about that because the "display dialog" was always presented to the "current" user. So, basically, Apple has removed the capability that existed in both Tiger and Leopard. Furthermore, their "solution" of using launchd doesn't cover this scenerio: - - remote launch of a UI application that warns the "current user", does a lot of cleanup work, and shuts down the computer.
I can do everything in a bash shell except present a dialog to give the "current user" a chance to Cancel. Basically, the myLogout application can be launched by the "current user", and since it doesn't have an input parameter, it doesn't wait or do the dialog. That works. But even when called from a bash-script WITHOUT a parameter (that's the "display" word in the sample), it still fails in Snow Leopard.
One final note: The "Product" listed with this post is NOT my Snow Leopard system, but it's NOT 10.4.11 either. I'm on 10.5.8

One of us is confused about something, and I'm not sure which of us it is.
What message are you trying to pass? If you want a formulaic "Shutdown in two minutes" message then code it directly into the script and don't bother with passing it. If you want a custom message that might change on different runs, then the easiest solution is to call a handler of the application on the remote machine and pass the message as a parameter.  just for an example, do this:
Put this script as a stay-open script application on the remote machine:
global idleInterval, message
on idle
          try
  -- error catching. when you call handler x(), first the script's run handler will run, then the idle handler, then x(), and the the idle handler in a loop. this prevents unset variable errors on the first pass.
  message
  idleInterval
          on error errstr
                    return 1
          end try
          if idleInterval is "Start" then
  say message
                    set idleInterval to 10
          else if idleInterval is 10 then
  say message
                    set idleInterval to 5
          else
                    display dialog "System wants to shut down"
                    set idleInterval to 1
                    quit
          end if
          return idleInterval
end idle
on x(textMessage)
          set idleInterval to "Start"
          set message to textMessage
end x
go back to the admin machine and run this command in the applescript editor:
tell application "ShowMsg" of machine remoteMachine
          x("Whoohoo!")
end tell
If it asks for authorization, give it. You can either save it in your keychain or we can work through the auth problem next.

Similar Messages

  • How can I get iTunes to display the tracks from a CD in their original (album) order?

    To be absolutely honest, I don't really understand what this box is for, so I shall just use it to repeat and expand on my question. (I have already sent a "Feedback" comment on the same topic).
    How can I get iTunes to display the tracks from a CD in their original (album) order?
    It seems to me that there is something very basic wrong with the way iTunes handles CD Tracks.
    Professionally produced CD tracks are seldom if ever in a randomised order. Why then does iTunes seem unable to display the tracks in the order they appear on the original CD source - whether from a personally owned CD or from a download from the iTunes Store?
    Some music demands a specific, non-alphabetic sequence in order to make sense. Why does it seem that iTunes only offers Alphabetic, or reverse alphabetic order - both of which make a nonsense of the original, often intended order of tracks?
    Why not replace the so-called "cover-art" in the bottom left hand corner if the iTunes window - which, while it may look attractive to some, gives the barest of information concerning the original disc, with a list of the original CD tracks in their original order, so that the user can easily reestablish the order in which they should be played.
    As I would expect legibility might be a problem with doing this, why could not the original contents, (in their original order), at least, be displayed when the "cover art" is double clicked-on - the result of which at present gives me an enlarged version of the "Cover Art". While on the subject of the contents of the source disc, what about all the album notes which someone takes trouble to write in order to increase the appreciation of the music on the CD and the listener's general background knowledge of the artists involved. Such notes, it seems to me, have considerable intrinsic value in their own account. I would, I think, normally be prepared to buy such "Sleeve notes" - so long as a "taster" was supplied (as it is for the music) - for something like the cost of a single 'Tune" on iTunes.
    These two aspects let Apple iTunes down enormously, in my opinion. I think that by chopping even quite protracted sequences of music up into bits does no one any favours - except perhaps Apple's already quite substantial bank balance. People have to be aware that two and a half, to three and a half minutes is a very short time to develop a piece of worthwhile music, and that there are many, many composers, not all of whom are alive today who have written music that huge masses of mankind value for the enrichment of their lives and the human condition in general.
    Please make the viewing of iTunes tracks in their correct order by default possible. By all means have the alphabetical variations available as offering a different approach to the music, but not the sole approach to it - PLEASE.
    Frustratedly yours
    Alan Whitaker
    PS I work at my old 24" iMac Intel Core 2 machine which runs OS "Tiger" - because it is more beautiful to look at, the screen is more pleasant to work on, and because, in some ways it is more capable (it will run FreeHand MX without needing a "patch"), than my more recent 21.5" which runs "Snow Leopard". (I don't find it that much slower, either).

    Dear Mike
    Thanks for the support. I am utterly amazed that after all the hype about how good iTunes is that it cannot play a downloaded CD in the correct order, and that what that order should be is not available directly from within one's own iTunes installation. (I know that one can go back to the iTunes Store to check what the order should be, but having downloaded the tracks surely iTunes is clever enough to retrieve this important information.
    My iTunes to differ from yours in that I have also noticed that it seems unable to download copies of my "talking books" in the correct order either. But in my case it downloads them - from a CD - in order, but with the first track downloaded first - so that it appears at the bottom of the column of tracks so that it would get played last! (At least this is, while being inexplicable, a relatively "logical" bit of blundering and because of this is relatively easy to put right!).
    I like many genres of music, some of which are not really programmed except perhaps by the artist performing them. I know that Frank Sinatra was very careful to programme his album songs to obtain a particular effect and in relation to the keys of the music. iTunes presumes to know better.
    Film scores may be totally randomly put together, in some cases, but in others the order is vital to one's appreciation of the music as a whole and how it relates to the plot of the film.
    In symphonic music most works are divided into sections and are conceived by the composer that way. Some individual sections may gain a life of their own if played separately, but they are never complete in the sense that the composer envisaged them without being placed in their proper context.
    Opera and probably most choral music too, is similar except that the words may well become meaningless if the order is changed at the whim of a piece of ill-written computer code, while ballet music has to be heard totally within its sequential context or it becomes meaningless.
    Finally, I would venture that iTunes, by jumbling up the order of the tracks as recorded on a CD, does an immense disservice, not only to the music on a particular CD, but to music in general, by expressing everything in terms of "Songs" - which it seems to interpret as stand-alone items of between 2 and 4 minutes whatever the genre. Even the way the iTunes publicity speaks of how many "songs" it can store instead of how many minutes or hours of recorded sound. This has to be another brick in the wall of "dumming-down" of people's expectations, and the shortening of their attention spans.
    I don't know about anyone else, but I feel betrayed by Apple over this. Perhaps the look, feel and general presentation of an item are not the most desirable features of a consumer product. Maybe it should be judged more on it fitness for the purpose for which it was sold. There is one other possibility - that Apple are trying to redefine "Music" - and that everything that lasts longer than about 3.5 minutes or is in the form of what could for want of a better term be called symphonic in the broadest sense is something else - not "Music" within Apple's new definition, at all!
    Well that's off my chest! now I can get down to creating some sort of order in my iTunes Libraries, knowing that I have to reconsult all the sources in order to confirm the source playing order.
    Anyway thanks again. At least I know that it is not just me
    alanfromthatcham

  • How can I set up Cinema Display as a main screen and leave my macbook pro as a second screen instead?

    How can I set up Cinema Display as a main screen and leave my macbook pro as a second screen instead?

    I learned that the Dock is positioned at the chosen edge of whatever Display is positioned farthest to that side.  E.g. for the Dock to be positioned on the right side of the Cinema Display (instead of the right side of the MacBook), the Cinema Display must be oriented (by dragging) to the right of the MacBook monitor on the "Arrangement" tab of the Displays Preference Panel.

  • How can i remote a computer outside of my nextwork and has a dynamic IP

    How can i remote a computer outside of my nextwork and has a dynamic IP.
    I have have mac set up overseas and will need to remote access it from time to time, but the mac has a dynamic IP, is there anyway around for me to access IT.
    Have been using "log me in" but its too slow.
    Thanks in advance for any assistance

    The subject of connecting ARD via the Internet has been covered here many times already (search the forum for "Internet"), but take a look at this web page:
    http://www.starklmc.com/ard.htm
    It should help, though you may have to refer to your router's documentation for specifics on opening and forward ports in that particular unit.
    To get a "static IP" use a service like dyndns.com

  • How can I add a second display to my Mac Mini

    How can I add a second display to my Mac Mini (mid 2011). HDTV and standard monitor working simultaneously.

    True ... but that can be tricky.
    Macs can only power so much, and only through approved/proper adapters.
    Running two monitors off a single MDP-to-VGA adapter may not work, because Mac may not nicely exchange-talk the simultaneous signals.
    There is an adapter that will convert a single minidisplayport to two VGA plugs, but that adapter is $100 instead of $30 (for the single) because it has special hardware in the adapter itself to manage the two signals sinultaneously.
    Alternately ...
    Running one through the minidisplayport and one through the HDMI port makes them two separate signals to be processed.

  • I have my boyfriend's apple ID and password, how do I check what apps he has on his phone? ( not all the apps that he had downloaded, but the ones that are actually on his phone). And How can I remotely download apps to his phone if I have his ID

    I have my boyfriend's apple ID and password, how do I check what apps he has on his phone? ( not all the apps that he had downloaded, but the ones that are actually on his phone). And How can I remotely download apps to his phone if I have his ID and PW?
    Thank you so much

    If you want seperate accounts for managing apps and purchasing content, basically yes, you need two account and would need to repurchase. However, if you just want seperate ID for iMessgae, icloud and such, you can do that and still continue sharing the same Id for apps and itunes.

  • How can I get my desktop display to go to 1440*900?thanks[solved]

    I am using KDE 4,My problem is I can't set my graphics display to 1440*900
    In my searching
    I've found this on the Ubuntu forum, which seems to be my issue. It doesn't matter what I set up in xorg.conf file, it ignores it.
    It references a file called "kcmrandrrc", which doesn't seem to exist on my system. I am not sure where KDE is getting the 320x200, 320x240, 400x300,...,640x480, 800x600 and 1024x768 graphics modes. It's not from xorg.conf.
    I found this file...
    "krandrrc"
    Which contains the following...
    [Screen_0]
    OutputsUnified=false
    UnifiedRect=0,0,0,0
    UnifiedRotation=1
    [Screen_0_Output_CRT1]
    Active=true
    Rect=0,0,1154,768
    RefreshRate=0
    Rotation=1
    How can I get my desktop display to go to 1440*900
    thanks
    Last edited by icywalk (2010-01-27 10:18:30)

    What I was looking for was something along these lines:
    Section "Screen"
    Identifier "Screen0"
    Device "Card0"
    Monitor "Monitor0"
    DefaultDepth 24
    Option "NvAGP" "3"
    Option "Overlay" "False"
    Option "ConnectToAcpid" "False"
    SubSection "Display"
    Depth 1
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 4
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 8
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 15
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 16
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 24
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 32
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    EndSection
    Then you put in the 1400x900 that you wanted in the Modes line.
    If you are to use Xorg -configure successfully, you will need to do it from a console screen.  If you are using like kdm or gdm,  I would suggest that you log out, then go to a console screen (<ctrl><alt><f1>) and then log in to an account.  You will need to su, and then issue the following command to shut down x: telinit 3  that command should shut down X and your login manager.
    After that you can run Xorg -configure and do whatever else you need with it.
    Then, to get back to what you had before, the command telinit 5 should restore you back to your gdm or kdm or whatever.  (Normally <Ctrl><Alt><F7> will get you back to your login manager, if it doesn't try F6 or F8 until you find it.)
    HTH

  • HT1338 how can i update to latest display driver

    how can i update to latest display driver i hv mini mac with i5 8gb

    by purchasing it from the app store.

  • How Can I have the MB display (1280X800) and a  1440 x 900 ext not in miror

    How Can I have the MB display (1280X800) and a 1440 x 900 ext not in miror mode ???
    I have a Lenovo external display :
    H19-inch (483-mm) viewable image size
    Optimum resolution: 1440 x 900
    Tilt stand for viewing comfort adjustments
    16 x 10 aspect ratio
    Analog attachment

    I just bought a wide screen display that also uses 1440 X900 resolution. In mirror mode mine also only allows a maximum of 1280 X ???. I think may be a limitation of the GMA 950 graphics chip set. I never use it in mirrow mode so it doesn't bother me. I prefer extended mode. That way I can keep more windows open and visible.
    I use the question mars because on mine I can use 1280 X any of the resolutions that go with it.

  • How can I get Launching report directory in report trigger??

    how can I get Launching report directory in report trigger??
    pls help me :'<
    I can run this function in forms.
    "how can I get Launching report directory in report trigger??"
    does reports have same function???

    Click the little down arrow/+ symbol  next the + - in the folders bar.

  • How can I create a my own dialog in awt or swings

    How can I create a my own dialog in awt or swings instead of JDialog,Joption.
    if possible some example.
    Thanks in advance
    bhaskar

    hi,
    just use the building blocks of of GUI components and their methods. For examlpe u want to write a Font Dialog box,
    use Frame with lists , thers is classes by which u can pick the all fonts installes on ur system. Do appropriate programming to event handlers . On last in event handler of 'OK' button get the selected item from list and assign to wht u want thats all...........

  • When I add a date to a cell, how can I let another cell display a date that is 30 days later?

    when I add a date to a cell, how can I let another cell display a date that is 30 days later?

    =[cell reference] +30

  • HT204407 How Can i remotely turn on find my iPhone app

    How Can i remotely turn on find my iPhone app

    Thank you. Not the answer I was hoping for though, but I appreciate your response

  • How can i remote iphone camera from macbook?

    I am trying set up photoshoot using iphone and macbook. How can i remote iphone camera from macbook? Thanks

    Not possible.

  • How can i call the certificate selection dialog box from source code?

    How can i call the certificate selection dialog box from source code?
    NB: Of course if i have more than one certificate in the Microsoft Keystore 'My'.
    Thank You in advance

    I found an example of the "TestStand UI Expression Control.ctl" and it works just the way I need it. (check the link)
    Proper use of "TestStand UI ExpressionEdit Control" in LabVIEW http://forums.ni.com/ni/board/message?board.id=330&requireLogin=False&thread.id=10609 
    The "Expression Browser Dialog Box Button" F(x) stays disable while editing the VI, however it become available when the VI is called from TestStand.
    Thank you,
    Hecuba
    Mfg. Test Engineer
    Certified LabVIEW Associate Developer

Maybe you are looking for

  • IOS SSL VPN WITH RADIUS Authorization

    Hi I'm trying to authenitcate and authorize  the users loggining into SSLVPN via ACS and although the ACS loggs and "TEST" command on the router shw succeeful authentication i receive the flollowing debug *Jun  6 22:39:50.157: %SSLVPN-5-SSL_TLS_CONNE

  • I have 2 Bookmark Toolbar Icons that are the same for 2 different locations. How can I change an Icon to avoid confusion?

    First location. https://www.blogger.com/blogin.g?blogspotURL=http%3A%2F%2Fmtbeautyband.blogspot.com%2F Second location. http://www.google.com.au/firefox?client=firefox-a&rls=org.mozilla:en-GB:official BOTH HAVE THE SAME ICON!

  • Importing from vinyl and tapes

    I am about to buy my first iPod, a shuffle. What is the best way to import music from vinyl records, and cassette tapes? How do I do it exactly? A lifetime of music and recrded material to be transfered. Thanks.

  • Cannot find type in assembly.

    I followed instruction in http://www.codeproject.com/Articles/19954/Execute-NET-Code-under-SQL-Server-2005 My dll is the following abbreviated.. Imports System Imports System.IO Imports System.Text Imports System.Data.SqlTypes Public Class CyDeC<Micr

  • How do I get folder sizes?

    How can I get the finder to calculate folder sizes? I've clicked Calculate all sizes in view options. Even when I ask for info on a particular folder, I get a blank. It gives the sizes of files but never for folders: just two little dashes Is this a