With systemsetup (see the man page here), you can control or view a lot of the same settings that are available in the graphical "System Preferences" tool. For example, the command:
systemsetup -setsleep off
will disable power management for disks, display and CPU. The separate parameters "-setcomputersleep", "-setdisplaysleep" and "-setharddisksleep" can be used to turn power management on/off for each. Specifying a number of minutes instead of "off" will turn power management on. (These settings can also be changed by editing /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist, but systemsetup provides a convenient interface that will -- presumably -- be independent of future structural changes in the plist file, and so can safely be used when developing scripts.)
Other examples, from the man page, are:
systemsetup -setdate 04:15:02
systemsetup -settime 16:20:00
systemsetup -settimezone US/Pacific
systemsetup -setnetworktimeserver time.apple.com
With networksetup (see the man page), you can configure or view network settings. For example, the command:
networksetup -getcomputername
will do the obvious. The command "networksetup -listallhardwareports" will show something like this:
Hardware Port: Bluetooth
Device: Bluetooth-Modem
Ethernet Address: N/A
Hardware Port: Built-in Ethernet
Device: en0
Ethernet Address: 00:16:cb:00:00:00
Hardware Port: Built-in FireWire
Device: fw0
Ethernet Address: 00:16:cb:ff:00:00:00:00
Hardware Port: AirPort
Device: en1
Ethernet Address: 00:16:cb:00:00:00
and "networksetup -getmacaddress en0" will return the wired network interface's MAC address.
Obviously, these commands only give access to a subset of the system's configuration parameters, but they're handy for many tasks.
No comments:
Post a Comment