Technote 019
Command line utilities for changing OS X network settings and system preferences
Problem:
How can I remotely change Mac OS X network settings and other system preferences on client computers?
Solution:
systemsetup and networksetup are command line configuration tools for machine and network settings in Mac OS X's system preferences. LANrev's Execute Shell Script command lets you remotely invoke systemsetup and networksetup on client machines to make changes to OS X's system preferences. These utilities are embedded within the Apple ARD client that is included in Mac OS X and can be found at the following path:
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support
With systemsetup you can:
- Set the current month, day, and year.
- Set the current time in 24-hour format.
- Set the local time zone.
- Enable network time.
- Designate a network time server.
- Set the amount of idle time until the computer sleeps.
- Set the amount of idle time until the display sleeps.
- Set the amount of idle time until the hard disk sleeps.
- Configure the computer to wake from sleep when modem activity is detected.
- Configure the computer to wake from sleep when a network admin packet is sent to it.
- Configure the computer to automatically restart after a power failure.
- Configure the computer to restart automatically after a system freeze.
- Enable remote login (SSH).
- Set the computer name.
- Set current startup disk to the indicated path.
- Set the number of seconds after which the computer will start up after a power failure.
With networksetup you can:
- Set the computer name.
- Set the TCP/IP configuration for the specified <networkservice> to manual and configure its IP address, subnet mask, and router address.
- Set the TCP/IP configuration for the specified <networkservice> to use DHCP.
- Specify a manual IP address to use for DHCP for the specified <networkservice>.
- Designate the search domain for the specified <networkservice>.
- Enable and change FTP proxy settings on <networkservice>.
- Enable and change Web proxy settings on <networkservice>.
- Enable and change Secure Web proxy settings for <networkservice>.
- Enable and change Streaming proxy settings for <networkservice>.
- Enable and change Gopher proxy settings for for <networkservice>.
- Enable and change SOCKS Firewall proxy settings for <networkservice>.
Where <networkservice> is usually "Built-in Ethernet."
The manual page found here for the systemsetup utility can provide you with a complete list of tasks the systemsetup command can perform and further instructions on usage. The manual page found here for the networksetup utility can provide you with a complete list of tasks the networksetup command can perform and further instructions on usage. When referencing either of these command line utilities in a shell script remember to specify the fully qualified path to these utilities inside the ARD application package itself. In the Execute Shell Script example below, which activates remote login (SSH), please note that there are exactly two lines of code.
#!/bin/sh
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/systemsetup -setremotelogin on
Note that the networksetup tool requires administrative privileges so you will need to enable the "Executable requires administrative privileges" checkbox in LANrev's Execute Shell Script dialog. You can view the output (if any) of your shell script in the History section of the LANrev Commands window by right-clicking the desired "Execute Unix Shell Script" entry and selecting "Show Command Result." |