Name

Network Setup Scripting

Synopsis

Commands are the action verbs that you use to script Network Setup Scripting, such as open database, close database, and connect (which you use to automate a modem’s connection to the Internet). The make command, for instance, allows a script to make a new network configuration, such as a TCP/IP configuration, “on the fly.” See the example under the make command section.

Dictionary commands

abort transaction

This command terminates a transaction. None of the changes that the script initiated within a begin/end transaction block will be completed. See begin transaction later in this chapter.

add reference

You can use this command to add a configuration such as a TCP/IP setting to Open Transport’s configuration sets. Configuration sets are, as they sound, a group of configurations.

to configuration set

This identifies the configuration set to add the configuration to, as in:

configuration set "My Network Settings" or current configuration set

Example

tell application "Network Setup Scripting" set tId to "" -- this var will hold the transaction ID try open database (*use this when the script is changing the open transport database; the var tId will hold the transaction id integer *) set tId to begin transaction add TCPIP v4 configuration "newMacIP" to¬ configuration set "My Network Settings" end transaction close database on error (* make sure transaction is aborted and database gets closed if there is an error *) if tId is not equal to "" then ...

Get AppleScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.