Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Combining UNIX commands into one task

Up until now I haven't played around with ARD much in terms of managing client settings, but recently I've been asked to change the energy saver settings on around 50 machines. I've collected the relevant terminal commands, and they all work individually. But I wanted to combine them all into one task. Can anyone tell me how this can be done? The only way I can think of would be to schedule the separate tasks in a queue.

Here's the series of commands I have ended up with:

defaults -currentHost write com.apple.screensaver idleTime 1
defaults write ~/Library/Preferences/ByHost/com.apple.screensaver.$(ifconfig en0 | awk '/ether/{gsub(/:/,"");print $2}') askForPassword -int 1
defaults -currentHost write com.apple.screensaver idleTime 0
# Set amount of idle time in minutes until a computer sleeps. Specify "Never" or "Off" for computers that should never sleep.
systemsetup -setsleep 45
# Set the amount of idle time in minutes until the hard disk sleeps.
systemsetup -setharddisksleep 90
# Set the amount of idle time in minutes until the display sleeps.
systemsetup -setdisplaysleep 15

Thanks

Posted on May 18, 2010 2:10 AM

Reply
4 replies

May 19, 2010 4:39 AM in response to Greg_P_Mills

I realise this may seem obvious to the more experienced users here, but simply putting colons in between the commands didn't work. I realised that some of these commands needed to be run as root, and some as the current user, so I had to split them into two tasks. Does anyone know how I can get around this? Sudo can't be used without user interaction, so is there another way of running the commands as root within the script?

Here's what I have now:

defaults write ~/Library/Preferences/ByHost/com.apple.screensaver.$(ifconfig en0 | awk '/ether/{gsub(/:/,"");print $2}') askForPassword -int 1; defaults -currentHost write com.apple.screensaver idleTime 0; systemsetup -setsleep 45 -setharddisksleep 45 -setdisplaysleep 15; pmset -a halfdim 1

Combining UNIX commands into one task

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.