Applescript to shutdown computers over local network

Hey guys!
I'm looking for a way to automate shutdown of 2 macs over a local network from a remote mac. I'm currently doing this by screen sharing in and shutting down both macs manually.
I have this untested theory that I could use my very basic knowledge of apple script to create a shutdown script on each mac and use an alias on the remote mac to run the script. However I am sure there is a much better way of doing this, I'm just lacking the know how! The script I want would ideally do as follows.
Run script from remote to Mac 1 and Mac 2 over network
Quit all running applications on Mac 1 and Mac 2
Shut down Mac 1 and Mac 2 in 5 minutes
If any one could help me imporve my laziness my giving me some pointers on this or even letting me know if its possible it would greatly appreciated!
Thanks!
C

Introduction:
I have tried a few things over my local network. My attempt to run a remote AppleScript nearly shutdown the Mac I was activating it from. There are probably ways around this but I decided to try something else.
The following is a very stable solution once you have got it working. Each Mac to be shut down watches a folder called shut-down and if its contents change the Mac shuts down in one minute.
I am sure this can be improved upon.
Let me know how you get on.
Permissions:
It is simple to do all this as root user as described below but without 'with administrator privileges' at the end of the AppleScript.
If doing it as admin use the AppleScript as below. The plist may need permissions set to root wheel.
The shut-down folder will need appropriate sharing permissions.
Create plist etc:
open TextEdit
create a new document
set TextEdit format to plain text
copy plist contents below
paste into the TextEdit document
save as shut-down.plist
put document in folder /Library/LaunchAgents on each Mac to be shut down
create folders entitled shut-down at the root of Macs to be shut down
run launch AppleScript below on each Mac to be shut down
Future changes to the shut-down folder's contents will shut down the Mac.
Contents of shut-down.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
          <key>Label</key>
          <string>shut-down</string>
          <key>ProgramArguments</key>
          <array>
                    <string>shutdown</string>
                    <string>-h</string>
                    <string>+1</string>
          </array>
          <key>WatchPaths</key>
          <array>
                    <string>/shut-down</string>
          </array>
</dict>
</plist>
Launch AppleScript:
Put the following on one line;
do shell script "launchctl unload -w /Library/LaunchAgents/shut-down.plist;  launchctl load -w /Library/LaunchAgents/shut-down.plist" with administrator privileges

Similar Messages

  • IPhone no longer connects to my computer over local network through apps

    I've been trying to fix this for months. I've worked with technology and Apple computers for three years. I am by no means an expert but you can believe me when I say I've tried all the basics.
    I first noticed the problem using FullControl. I liked to use this first thing in the morning. One morning it wouldn't connect, "Error: Connection error (22)." I hadn't updated or changed anything. I actually put my computer to sleep the night before using the app! I was on the local network. My computer was running the helper. My computer was showing up as a device in the app. But it would not connect. I figured something was wrong with the app.
    So I opened up Splashtop 2. My iMac showed up in my list but with a satelite icon informing me it was not connecting on the local network. I was still on my wifi as was my computer. I used it earlier that week.
    I checked out the support pages for both apps. I updated everything. I turned off, on, and checked the connections for my firewall. I turned off my security applications and followed guides to remedy blocks they might cause. Nothing worked.
    I checked Apple discussions and found people having similar issues but no one had a fix. A few found success but nothing worked for me.
    A few days later I went to use my Remote app. My iTunes Library showed up in the local devices but it would not connect, "Remote can't connect to your iTunes library. Check your network settings and try again." I checked. Tried again. "Could not find [my] Library." I went back to the devices and connected to my Apple TV 2 instantly. I tried connecting my iMac with the Apple TV and found no issues. Each communicated with the other fine. I tried to connect Remote to my iTunes again but it failed.
    I verified and repaired my permissions. I thought the "SUID... ARDAgent.app... [permission] has been modified and will not be repaired" could've been the problem but Apple and these Discussions assure me that this is normal and not a problem.
    I recently downloaded Air Playit and ran into the same problem. I set it up on my computer following the instructions. I opened the app. The app showed my computer as a "Computer on Local Network" but when I tried to connect to server, "Connect Server Failed: Cannot connect the server, check the IP, Port and try again." I did and it didn't connect.
    Save for this new app, everything worked before. Nothing has worked since that morning FullContol failed (including the new app).
    Is there an answer out there?!
    iPhone 5 iOS 6.1.4: updated as of 06-29-2013
    iMac 2007 OS X 10.6.8: updated as of 06-29-2013
    FullControl (Full version)
    Splashtop 2 (Full access)
    Remote
    Air Playit
    - All apps and applications updated as of 06-29-2013

    Intego's VirusBarrier X6 was blocking my iPhone's connection.
    I saw that the program was blocking attempts to connect and took the address off the Blocked list. I instantly connected through everything again. It turned out to be a major oversight and easy fix!
    If anyone else is having similar issues, check your AntiVandal software and make sure your devices are not being blocked.

  • ARD not finding any computers on local network scan

    I've installed ARD 3.2.2 on a g5 xserv and when I use the scanner to scan the local network I find no computers. If I change to Bonjour, network address, or network range I can find computers. My xserv has the nics teamed through hp procurve managed switches. ARD 3.2.1 worked fine on this box when it was 10.4.11 but I'm not sure if the nics were teamed. Has anyone else found similar behavior with teamed nics or is this an ARD 3.2.2 problem?

    I forgot to mention that I'm also running a different copy of ARD 3.2.2 on my macbook pro and the scanning the local network returns all the computers on our network. The xserv in question is setup to be a task server but still shows the problem without being a task server.

  • Unable to connect to Windows computers on local network

    We have several Windows XP computers on our local network. Some have shared folders, that we can upload/download files to/from. 
    Connecting to these Windows computers was no problem under Snow Leopard, but under Lion I cannot connect to any of them.
    The shared computers show up in the Finder. I can see them in the sidebar, under the "SHARED" items. But I cannot connect to them.
    If I select a computer to connect to, the Finder pops up the following error:
    There was a problem connecting to the server "name".
    The server may not exist or it is unavailable at this time. Check the server name or IP address, check your network connection, and then try again.
    Also, I get the following error message in the system.log
    Finder: SharePointBrowser::handleOpenCallBack returned 57

    Unfortunately it does not work for me.
    I can see the server in the Finder under the "Shared" list.
    If I click on the server, the Finder gives me the error message I mentioned above. If I click "Connect to server" button nothing happens, but I get the same error message in the system.log. If I select the "Connect to Server" option from the "Go" menu I get the same errors. So I still cannot connect.

  • CS3 slow over local network

    I'm on a MacBook Pro 2.33GHZ Core 2 Duo w/2GB RAM.
    Websites are shared from a Windows XP machine using normal
    built in file sharing.
    In Dreamweaver CS3, opening a document takes a while. And
    once it's open and everything looks good, I can click on an image
    and count out 2 seconds before the image actually highlights. Click
    on another image or in a table cell to type text, and it's another
    two seconds.
    This site website, copied to my own hard drive, responds as
    fast as it should - near instant.
    The website and images aren't large by any means, 43k with
    HTML, images, and css. It seems weird that it'd be slower over the
    network than locally. Once Dreamweaver has the document open and
    everything loaded, just selecting different elements shouldn't take
    a performance hit.
    I didn't have this problem with Dreamweaver 8.
    Anyone else having this issue? Any suggestions?
    Thanks,
    Ryan

    Hi theand
    Thanks for going through the Mac troubleshooting TechNote.
    Sorry it didn't
    help.
    1. Can you please send us a bug report so we can get your
    contact info?
    Please let us know that you are "theand":
    http://www.adobe.com/go/wish
    2. Can you reproduce this problem on another Mac connecting
    to your same
    server?
    3. On your Mac, in the Site Definition, how do you have the
    Local Info and
    Remote Info sections filled out?
    4. Do you have any sites that use an FTP server? Do those
    sites have the
    same problem?
    5. What kind of server are you connecting to in your local
    network?
    Thanks,
    David Alcala
    Adobe Product Support
    "theand" <[email protected]> wrote in
    message
    news:f0db3f$rgk$[email protected]..
    > I've followed every suggestion on the general Mac OSX
    troubleshooting tech
    > note
    > and none of them helped.
    >
    >
    2. Can you reproduce the problem in a new site definition using
    a new
    > local
    > root folder that only contains one file? Setup this site
    so it has no
    > remote access (i.e. no FTP, Local Network, etc.)
    >
    > I have an existing site which is on my hard drive and
    does not produce the
    > problem. If I then go back to a site served across our
    local network the
    > beachball appears as soon as I open a file, not before.
    After about 30
    > secs to
    > a minute it will free up then if i click anywhere or
    scroll it will beach
    > ball
    > again and so on.
    >
    >
    3. Does your site have a lot of files and subfolders?
    >
    > The sites on the network have a lot of files and
    subfolders. DW8 worked
    > with
    > them fine however.
    >
    >
    4. Does the problem only happen if you have DW open for a long
    time or
    > can
    > you reproduce it right after opening DW?
    >
    > It happens as soon as I open a file immediately after
    launch.
    >

  • Copying itunes library from Mac to Windows over Local Network

    I am a recent switcher. When I first got my MacBook I connected my Windows formatted iPod to the MacBook to transfer my purchased iTunes music, and everything worked fine.
    Now I want to transfer the iTunes music folder from my Mac to a PC (both Vista and XP) over my local network. However, when I try to do this I get the following error message:
    Error 0x800700FE: The specified extended attribute name was invalid.
    I get the same error message if I try to transfer the individual music folders (eg Oasis).
    I have no trouble transferring the folders for song/albums that I have subsequently downloaded to the Mac from iTunes. I only have the problem with the music I originally transferred from the iPod.
    I have been trying to research extended attributes to see if I can edit this, but it all goes over my head. Any advice would be greatly appreciated.

    Hello,
    i'm also a new Mac user (Vista did the trick , and i found this article on the Apple support website.
    Below information can also be used to do the inverse... Mac to PC.
    http://docs.info.apple.com/article.html?artnum=302392
    It explains how to do a backup to CD/DVD. When you have a large library, multiple DVD's will be used.
    It tried it out with a portion of my lib, burned a backup with my PC, and imported it on my MacBook. Works great! All but last played information is copied over...
    Even Podcast, Movies etc are taken into account, also music not residing within the iTunes folder. After the restore on Mac, everything is properly placed within the iTunes folder you assigned.
    Enjoy,
    Roger
    PS: in fact this article is "on the top" of the following list: http://www.apple.com/support/itunes/ :-))

  • Over local network file copying stays at Zero Bytes...

    I am not sure what section to put this under or what is causing the problem.  It seems I cant access files over my home network any more.
    My wife has a 2.4 c2d Macbook running 10.7.2, I have a 2.4 c2d iMac running 10.7.2, and we use an AirPort Extreme base station.
    She has a user set up on my computer so she can connect over the network.  File sharing and Print sharing are enabled.  She has been added to the external drive with the files on it as a read only user.  Everything has worked well until very recently.
    First Playback, the program I use for uPnP streaming to my xbox, ceases to function.  To the best I can find, that is due to a change in how the xbox requests files since a recent update.  Not an apple problem but it did spur me to use a more direct approach: Plug the laptop to the television and open the file via my wife's macbook.  After connecting to my imac over the local wireless network and browsing to the file, I first attempted to directly open the video.  This method has worked well in the past.  I took about 5 minutes before quicktime launched.  Quicktime did report the run time of the video but failed to ever display any frames and effectively froze.  I shut down the macbook, rebooted.  This time after browsing to the file I attempted to copy it over the network to her computer.  This resulted in finder making it so far as to actually say Copying the file but the progress remained at Zero Bytes and the progress bar never resized.  After 10 minutes like this, I canceled that transfer and waited until that process closed.  I chose another file that had a thumbnail instead of the quicktime icon in hopes of better compatability.  The quick look preview began to spiral and I got the rainbow wheel as a cursor.  I never got the oportunity to begin to attempt the new file.  I had to reboot the macbook again to stop that process.
    Placing the original file on a usb stick and then again on her computer has allowed me to open the file on both machines.
    When I first switched from windows, fixing these types of issues often confused me as I looked for the complex windowsesque settings and options.  I often miss the simple and obvious way to fix most mac problems.  Any help would be greatly appreciated.

    Normal. See:
    http://reviews.cnet.com/8301-13727_7-20093292-263/lockfiles-and-other-plist-file -subtypes-in-os-x-lion/
    Regards.

  • Quicktime very slow to load files over local network

    I've had this issue before and managed to resolve it, but recently it's cropped back up and I've been unable to fix it.
    If I attempt to load a movie file with Quicktime over my local network, Quicktime stops responding... it will eventually spring to life and open the video after a few minutes.
    Before, I was recommended to install Perian and did so. That solved that issue immediately. However, in more recent releases of Quicktime, the issue has reappeared and even reinstalling Perian has done nothing.
    Any insight?

    BT FON is an open network that does not use wireless encryption, so it will be slightly faster anyway, however as your problem seems to be with your main SSID, its possible that there is some incompatibility between your wireless card, and the home hub.
    Try changing the wireless encyption on the home hub to WPA only, and not WPA/WPA2. Some wireless cards do not like mixed mode encryption.
    There may be an update to your wireless card drivers.
    There are some useful help pages here, for BT Broadband customers only, on my personal website.
    BT Broadband customers - help with broadband, WiFi, networking, e-mail and phones.

  • Using the same library with multiple computers over a network Use Aperture

    Hi Everyone. I am researching some cataloguing/editing programs to recommend one to my boss, and I was wondering if it was possible to use the same library between multiple computers on a network. Does anyone know if this is possible? This may be what makes or breaks the decision on whether or not to go with Aperture as we need a program that can access a large database of photos on multiple computers.
    Thank you.

    Welcome to the forum.
    You can do it, but...
    It's not supported by Apple.
    Performance won't be great unless you're running a really fast network.
    If more than one person tries to access the Library at one time you're likely to end up with a corrupted database, and there's no code in Aperture to limit access to one person at a time.
    The Library must be stored on an HFS+ volume - don't even try putting it on a FAT32-formatted drive.
    If you want 'proper' multi-concurrent-user network-enabled cataloguing software you're looking into a whole different level of investment than the low price of Aperture - think more in terms of thousands or even tens of thousands of dollars.
    Ian

  • Pinging computers on local network

    Hi,
    I am having problems pinging clients on my location network (192.168.0.x) by there host name.  Is there a tutorial or thinks I should check to get that working?
    Thanks for the help!

    tjwallace wrote:I thought it would do hostname lookup automatically, without having to populate /etc/hosts.  Also all the other hosts are using DHCP so their IP could change.
    I only use D-Link routers, so I can't speak for other routers.  With my D-Link I can set up the DHCP server on the LAN side to use a range of IP addresses for DHCP, say 192.168.0.2 to 192.168.0.100.  All DHCP leases will be set up in that range.  Then 192.168.0.101 to 192.168.0.254 can be used for static addresses.  The D-Link will serve both types of addresses simultaneously, DHCP and static.  You could set up the Windows boxes on the DHCP part and your Linux boxes in the static address area.
    Or, you could do like I do.  I have static addresses on all my computers.  Six Arch Linux boxes, and two Windows XP boxes.  If you are going to network multiple computers, and some of them are Linux boxes, static addresses really save a lot of head aches.
    Here is a tutorial I wrote for setting up ssh and sshfs on Arch Linux.  It may be of use to you.  I use the sshfs setup for Linux to Linux networking, and SAMBA for Linux to Windows networking.
    Pudge

  • How do I share info between my two computers over my network?

    Hello !
    I have an iMac, my husband has a Macbook. I just recently got an AEBS so that we could share the internet in the house. We are both wirelessy connected (thanks to the help on this forum). But I am wondering HOW can I share info on my computer...with his macbook? On HIS computer I can see a "shared" option on his HD, and my iMac is listed. It asks for password to access it. But I never set up this sort of sharing. I tried looking around on the iMac last night to figure out where I would do this, but to no avail. And I'm afraid to do something in fear of messing something else up !
    I guess I have no idea how this "networking" thing really works. Any help would be appreciated !
    Thanks for your help in advance.
    Christine

    +Ok...so I went to the system pref/account tab. and I see where the password is for my iMac. Is that the password he would use to access the computer from his? the same one I use to access my own computer?+
    Yes, correct. When he "logs on" to your computer from his, he will be given the option for KeyChain access on his computer to "remember" the password so he won't have to manually enter the password each time he connects to your computer.
    Same thing in reverse when you connect to his.
    In most cases, the only thing you really need to share are the "printer" and "files", but you have a number of other options as well.

  • Can't connect to MPD over local network - control [solved]

    I have a laptop running Arch Linux. I recently purchased an O2 Joggler, and installed Ubuntu Netbook Remix on a USB drive for it (AWESOME, btw). My idea was to use the joggler as a remote control for my laptop, which is often running MPD to listen to my music collect (I'm also using it for light browser etc.)
    However, my setup just now isn't allowing me this. Here are some configs that will hopefully help the diagnosis
    mpd.conf:
    music_directory "/home/iain/Music" # Your music dir.
    playlist_directory "/home/iain/.mpd/playlists"
    db_file "/home/iain/.mpd/db"
    log_file "/home/iain/.mpd/mpd.log"
    error_file "/home/iain/.mpd/mpd.error"
    pid_file "/home/iain/.mpd/mpd.pid"
    state_file "/home/iain/.mpd/mpdstate"
    user "iain"
    port "6666"
    bind_to_address "any"
    #password "mpd@read,add,control"
    default_permissions "read,add,control"
    log_level "verbose"
    audio_output {
    type "alsa"
    name "Sound Card"
    options "dev=dmixer"
    device "plug:dmixer"
    format "48000:16:2"
    mixer_type "alsa"
    # mixer_device "default"
    # mixer_control "Alpha"
    #auto_resample "no"
    /etc/hosts.allow:
    # /etc/hosts.allow
    #ALL:ALL:ALL
    MPD: ALL
    # End of file
    /etc/hosts.deny:
    # /etc/hosts.deny
    ALL: ALL: DENY
    # End of file
    I'm trying to connect FROM my joggler to my laptop which is running MPD. The laptop's local IP is 192.168.1.70.
    I know how awesomely useful the Arch user on these forums are (I've need the help A LOT in the past), so I'm hoping one of you clever lot can help me holmes' this problem.
    Thanks,
    pritchard92
    Last edited by pritchard92 (2010-05-25 14:35:16)

    A hint to open a port
    iptables -A INPUT -p tcp -m tcp -s 0/0 --dport <portno> -j ACCEPT.   with the port number for eg 8600 is used to open up the mpd streaming for me.(in arno firewall script you can set these in custom.rules. The rules may differ in your case. A search will give tons of options.

  • Show IP Addresses of Computers on Local Network

    Is there a handy terminal command that can show this data for me? Iptraf can show hardward addresses, but I am looking for IPs

    $ nmap 192.168.1.0/24
    Starting Nmap 5.21 ( http://nmap.org ) at 2010-10-14 22:09 ART
    Nmap scan report for 192.168.1.1
    Host is up (0.0075s latency).
    Not shown: 995 filtered ports
    PORT STATE SERVICE
    20/tcp closed ftp-data
    21/tcp closed ftp
    23/tcp closed telnet
    80/tcp open http
    113/tcp closed auth
    Nmap scan report for 192.168.1.2
    Host is up (0.00056s latency).
    Not shown: 995 closed ports
    PORT STATE SERVICE
    22/tcp open ssh
    80/tcp open http
    111/tcp open rpcbind
    2049/tcp open nfs
    3306/tcp open mysql
    Nmap done: 256 IP addresses (2 hosts up) scanned in 11.51 seconds
    This is quite handy

  • [Newbie] FMS not visible in local network

    Hi,
    I have a problem with FMS 3.5 installed on Windows 7. The problem is that FMS works only on my local machine, I am not able to use it from computers in local network. I turned off all windows firewalls and my machine is visible for other computers - I am able to connect to FMS Welcome site on apache on default port 8134, but streaming fails, and I cannot do the same on port 80. Any help appreciated...

    From fms.ini:
    # IP address and port(s) Flash Media Server should listen on
    # For example:
    #    ADAPTOR.HOSTPORT = :1935,80
    ADAPTOR.HOSTPORT = :1935,80
    # IP (address and) port that Flash Media Server should proxy
    # unknown HTTP requests to. Leave empty to disable proxying.
    # With no address, specifies a localhost port.
    # For example:
    #    HTTPPROXY.HOST = webfarm.example.com:80
    HTTPPROXY.HOST = :8134
    So I believe it is...
    What can I do if connections are not reaching FMS?

  • Sharing an address book over a local network - is .Mac required?

    We have a smal Mac ethernet network of 4 or five macs all running OSX 10.3 or above and all with Administrator access. Each mac is used by one member of staff only. One member of staff maintains our client/supplier contacts database as an Excel worksheet on one of the macs, for mail merging with Word, marketing mail shots and other correspondence etc.
    Other staff on the network need access to those up-to-date contacts on a daily basis and it is a pain accessing the Excel file all the time accross the network. I have my own pesonal .Mac membership account and I have successfully experimented with exporting the Excel file as a formatted text file (.txt) and importing the relevant fields from the file into Address Book. I intend empowering the 'contacts maintainer' to import the Excel contacts into her macs address book at periodic intervals....
    Based on this scenario, my questions are as follows:
    a) Can other staff access/share her address book contacts over the network in their local copy of Address Book without a .Mac account?
    b) If she is set up with a .Mac account on her Mac...
    i) I can subscribe to her address book through my copy of Address Book as I have a .Mac account already - how will this display in my Address Book (Will it automatically creat a new Group?)
    ii) Do other staff have to have individual .Mac accounts in order to subscribe to her Address Book contacts (and do they need the full .Mac Membership) – Could they not simply enter her .Mac member details in their macs System Prefs>.Mac>Account and then synchronise Contacts (and possibly iCal Calendars) as this is all they would require it for?
    c) Is there a simpler way to achieve all this at minimal cost?
    d) Is Directory Access>Contacts involved in a possible alternative solution or am I 'barking up the wrong tree'?
    Would appreciate some help with this ASAP!
    DMC

    Hi Dozza,
    The good news is YES, sharing an Address Book group(s) is easily done without .Mac
    Since you are on an ethernet network, all you need to do is:
    1. Enable Sharing thru System Preferences from your "main" computer you wish to transfer data from/with.
    2. Drag your AB group(s) or individual cards to the desktop of your main computer - the one you have all the info in... (the cards will convert to vCards automatically.
    3. Place those groups or cards in your Drop Box folder which is: Hard Drive>Users>your "Home" folder>Public>Drop Box
    4. All networked computers will be able to access your Drop Box folder even if you do not want other info shared.
    Of course .Mac is pretty darn handy too!
    Good Luck
    John

Maybe you are looking for

  • Ipod will not turn on and is not recognized by windows to restore it

    I have a 30g video ipod that worked fine for about a week. Today i tried to turn it on and i got the sad face with the website for apple support. I tried the 5 R's but nothing worked. I can't get the ipod to go into disk mode and i can't restore it b

  • Capture Image Of A Very Large JPanel

    Below is some code used to save an image of a JPanel to a file...     int w = panel.getSize().width;     int h = panel.getSize().height;     BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);     Graphics graphics = image.getG

  • How can I type different languages for imovie title?

    Im trying to create a tittle in Thái ? How can I do that? I have no problem typing in English. Thanks

  • IOS 4.0 -- Wallpaper on locked screen?

    My iPod used to have a picture display when the iPod was locked. Now it's been replaced with a picture of the battery level. How do I get this back? I found the options for setting a wallpaper, but it doesn't seem to affect anything. I understand the

  • The configured database is not a compatible database

    Hi, i am experiencing some problems getting our zen servers to carry out reporting, auditing, etc etc. Running : Netware 6.5 sp5 Zenworks Desktops managment 6.5sp1 When i attempt to carry out a report or click on the zenworks inventory databse object