O'Reilly logo

AppleScript in a Nutshell by Bruce W. Perry

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required