Team LiB   Previous Section   Next Section
Apple System Profiler

Syntax

tell app "Apple System Profiler"

   (* get the machine's IP address *)

   get TCPIP address

end tell

Dictionary commands

open object or list of objects

This command opens an ASP report, as in the following example:

set rep to "macintosh hd:desktop folder:ASP report" as alias 

tell application "Apple System Profiler"

   activate bring ASP to the front

   open rep

end tell
print object or list of objects to print

This prints a report, as in print ASPreportFile displaying print dialog true as text.

displaying print dialog (boolean)

This is an optional true/false value. If it's true, it displays a dialog for setting printing preferences prior to printing the ASP report.

as (text/shown on screen)

This is an optional labeled parameter involving whether to print out the report as text or as it is laid out on screen in the ASP document.

quit

This command quits ASP.

run

This command sends a run Apple event to ASP, which is the same as double-clicking the program's icon on the desktop. This opens the application if it is not already open.

close reference to object

This closes an ASP report, optionally saving it in a file. Here is example code:

close report "ASPreport" saving ask

saving yes/no/ask

The optional saving labeled parameter takes one of three constants. yes saves the report with a default name in ASP's directory (which is the Apple Menu Items folder), no just closes the report without saving it, and ask displays a dialog that the user can use optionally to rename the document and save it in the directory of his choice.

saving in alias

Using the code

close report report 1 saving in aliasFile

saves an open report in the alias contained in the variable aliasFile.

count reference to object

This command counts the number of open reports or ASP windows and returns an integer:

count each window

each class

The each labeled parameter, as in count each report, is not required; you can use syntax such as count reports instead.

exists reference to object

This finds out whether a report or window exists:

exists report 1

This command returns a boolean value, true or false.

make

This command makes a new report:

make new report at "macintosh hd:desktop folder" with properties {report 

contents: {system profile} }

A report is the only object that ASP can use make with.

new (class)

Follow the new labeled parameter with the report class type:

make new report

at (location reference)

Follow the at labeled parameter with a string indicating where you want to save the report:

at "macintosh hd:desktop folder"
with data (anything)

This labeled parameter does not appear to add any value in this context beyond what you can accomplish with the with properties labeled parameter. At any rate, follow this labeled parameter with an anything value.

with properties (record)

The with properties parameter is followed by a record type that contains the new report's properties. Chapter 3,describes the record data type. Here is the example code:

tell application "Apple System Profiler"

   make new report at 

      "macintosh hd:desktop folder" with properties 

      {report contents:{hardware overview}, 

      report view format:text}

end tell
save reference to report

You can save an ASP report to a file with code such as:

save report 1 in "macintosh hd:desktop folder:new.txt"

in (alias)

If you pass in a valid string pathname with the in labeled parameter, then ASP saves the report in a new file.

backup (boolean)

The backup true labeled parameter is not necessary; if you continually save the same report but with different filenames, the original saved report is not overwritten. These actions will just create several different files of the same ASP report.

Dictionary classes

application

This class represents the Apple System Profiler app. It includes the window and report elements, as well as numerous properties that contain information on the computer's memory, such as volumes (disks), files, networking protocols, and other features. Scripters can set non-read-only ASP properties with code such as:

tell app "Apple System Profiler" to set report contents to¬

   memory overview

You can get information about the machine with code such as the following:

get QuickTime version or get file sharing

This is true or false if file sharing is enabled. The phrase "(report class)" in the following definitions means that the report class shares this property with the application class, and the property has the same definition. The following are application elements:

report

The application can have one or more open ASP reports. See the report class.

window

The application can have one or more open ASP windows. See the window class.

The following are application properties:

properties

The code:

tell app "Apple System Profiler" to get properties

returns a record type containing the names and values of the vast majority of the application's properties. To get a specific property value from this record type, use code such as:

get AppleTalk address of properties

This useful property returns the hardware address of your Ethernet card as a string, such as "08.00.07.00.00.00."

clipboard (a list of anything)

This returns a list of whatever items are in the clipboard.

name (international text)

The name is "Apple System Profiler."

frontmost (boolean)

This value is true if ASP is the frontmost app on the desktop.

version (version)

This returns the ASP version number, which is a string like "2.4.4." Version 2.4.4 comes with Mac OS 9.04 and includes the dictionary described in this chapter.

gathers at launch (list of constants)

This property tells ASP which machine data to gather when it starts up or launches. You can also set this property by choosing ASP's menu command Edit-Preferences. The constants are any of the following:

all
network overview
applications
printing overview
control panels
production information
devices and volumes
software overview
extensions
system folders
hardware overview
system profile
memory overview

Here is example code:

set gathers at launch to {network overview, system folders}.
gathering (boolean)

This is a boolean value that returns true if the application is in the process of collecting data on the machine.

remembers window size (boolean)

This sets the "save window location and size" checkbox in the Preferences window of the app.

report view format (text/shown on screen)

You can set this property to either of the two constants. There are slight differences in the way the two constants display the ASP data (for example, text is better for printing the document).

preferred report contents (a list of constants)

You can set this property to any of these constants:

all
network overview
applications
printing overview
control panels
production information
devices and volumes
software overview
extensions
system folders
hardware overview
system profile
memory overview

The setting determines the default manner in which ASP gathers machine data.

control panel volumes (list of aliases or the constants startup/attached /all /preferred)

Usually ASP just gathers information that derives from the startup disk, but your computer might mount more than one volume on the desktop. This property determines whether you gather data on the control panels of only the startup disk or of several other volumes. You can use a list of aliases to the various volumes or one of the constants to give this property a value:

set control panel volumes to attached
extension volumes (list of aliases or the constants startup/attached/all/preferred)

Using this property, you can control where ASP gathers information from on extension files. Use a list of aliases to the volumes or one of the four constants to give this property a value.

application volumes (list of aliases or the constants startup/attached/all/preferred)

Usually ASP just gathers information that derives from the startup disk, but your computer might mount more than one volume on the desktop. You can control where ASP gathers information on applications. Use a list of aliases to the volumes or one of the four constants to give this property a value.

system folder volumes (list of aliases or the startup/attached/all/preferred)

Scripters can specify the system folders that ASP gathers data on by setting this property to either a list of aliases pointing to the system folders or one of four constants. The default is startup.

system info (record)(report class)

This property returns a record containing data from the system overview section of the System Profile panel. An example return value is:

{file sharing:true, finder version:"9.0", system version:"9.0.4

US", active enabler:"PowerPC Enabler 9.0.4 9.0.4", AtEase version:"1.1",

QuickTime version:"4.0.3", StartupDiskName:"Macintosh HD", MacOS info:true, 

StartupDiskType:"Hard drive", StartupDiskLocation:"ID = 0", 

StartupDiskBus:"SCSI Bus 0", disk cache size:"6.50 MB", startup info:true, 

system info:true}.
MacOS info (record)(report class)

This gathers all of the information from the Mac OS overview section of the System Profile panel. This property returns a record type. Chapter 3describes the record data type.

finder version (string)(report class)

This returns the version of the Finder from the frontmost ASP window or report.

system version (string)(report class)

This property returns a string containing the system version (e.g., "9.04") from the frontmost ASP window or report.

active enabler (string)(report class)

This property returns the version of the active enabler system software or an empty string if there isn't one installed.

AtEase version (string)(report class)

This is the version of the software At Ease, if it's installed.

MultipleUsers user name (string)(report class)

This returns the current username if Multiple Users is installed and a user is logged in.

MultipleUsersEnvironment (string)(report class)

This property returns information on the Multiple Users environment if Multiple Users is installed and a user is logged in.

QuickTime version (string)(report class)

This property finds out which Quicktime version the machine is running with code such as:

set qt to QuickTime version
file sharing (boolean)(report class):

This is a true or false value indicating whether file sharing is enabled.

startup info (record)(report class)

This property returns a record containing useful system information such as your machine's disk-cache size. The return value from get startup info looks like:

{StartupDiskType:"Hard drive", StartupDiskLocation: "ID = 0", 

StartupDiskBus:"SCSI Bus 0", disk cache size:"6.50 MB", startup info:true}
StartupDiskName (string)(report class)

This property returns the name of your startup disk.

StartupDiskType (string)(report class)

This returns a string such as "Hard drive."

StartupDiskLocation (string)(report class)

This property returns a string such as "ID = 0."

StartupDiskBus (string)(report class)

This returns a string from the startup device section of the System Profile panel, such as "SCSI Bus 0."

memory info (string)(report class)

This is a record type whose return value looks like:


{video memory size:"", memory cache size:"Not installed", VM info:true, 

VM size:"209 MB", VM storage:"scratch", physical RAM size:"208 MB", 

memory info:true}
disk cache size (string)(report class)

This property returns the disk cache string from the memory overview section of the System Profile panel. An example is "6.50 MB."

video memory size (string)(report class)

This property returns the video memory size or an empty string if the data is not available.

video note (string)(report class)

This property returns nothing on my machine, but returns a string if Video note information is available.

memory cache size (string)(report class)

This property returns "Not Installed" if the external L2 cache is disabled on your motherboard, as is true for my CPU-upgraded machine.

VM info (boolean)(report class)

This is a true/false value indicating whether virtual memory is turned on.

VM storage(string)(report class)

This property returns the name of the volume or disk that is storing the virtual-memory file, if virtual memory is turned on.

VM size (string)(report class)

This returns a string representing the amount of virtual memory the machine is using; it returns an empty string otherwise.

physical RAM size (string)(report class)

This property returns the amount of memory the machine has.

hardware info (record)(report class)

This returns a record type containing the information that is found in the hardware-overview section of the System Profile panel. Here's a sample return value:

{logicboard num:"69", unique logicboard num:"69", 

model name:"Power Macintosh 8500 series", keyboard type:"Apple 

Extended Keyboard", hardware attributes:"Not available", 

processor type:"PowerPC G3", rated speed:"400 MHz", processors:"1", 

nanokernel version:"2.13", free pools:" 0", scheduled processors:" 1", 

hardware info:true}.
logicboard num (string)(report class)

This represents a subset of the hardware-info value (see the example return value under "hardware info").

The following 10 properties represent a subset of the hardware info value (see the example return under "hardware info"):

unique logicboard num (string)(report class)
rated speed (string)(report class)
model name (string)(report class)
keyboard type (string)(report class)
hardware attributes (string)(report class)
processor type (string)(report class)
processors (string)(report class)
nanokernel version (string)(report class)
free pools (string)(report class)
scheduled processors (string)(report class)
network info (record)(report class)

All of the available AppleTalk, Ethernet, modem, and other networking information (including TCP/IP address and subnet mask) is returned as a record type. In other words, this is a very useful value for anyone who is dealing with networked Macs. The data derives from the network-overview section of ASP's System Profile.

Ethernet information (record)(report class)

This property returns a record type containing the values for Ethernet link, duplex, and speed.

Ethernet link (string)(report class)

This returns the Ethernet link value from the network-overview section of ASP's System Profile tab.

Ethernet speed (string)(report class)

This returns the Ethernet speed value from the network-overview section of ASP's System Profile tab.

Ethernet duplex (string)(report class)

This returns the Ethernet duplex value from the network-overview section of ASP's System Profile tab.

modem info (string)(report class)

This property returns the modem info value from the network-overview section of ASP's System Profile tab.

modem name (string)(report class)

This property returns the modem name value from the network-overview section of ASP's System Profile tab.

modem protocol (string)(report class)

This property returns the modem protocol value from the network-overview section of ASP's System Profile tab.

modem version (string)(report class)

This property returns the modem version value from the network-overview section of ASP's System Profile tab.

modem status (string)(report class)

This property returns the modem status value from the network-overview section of ASP's System Profile tab.

Open Transport info (record)(report class)

This property returns a record type containing information derived from the network-overview section of the System Profile tab. The following is a sample return value:

{Open Transport installed:true, Open Transport status:true, Open Transport 

version:"2.6.1", Open Transport info:true}.
Open Transport installed (boolean)(report class), Open Transport status (boolean)(report class), Open Transport version (string)(report class)

These properties return a subset of the Open Transport info value. See Open Transport info for a sample return value.

AppleTalk info (record)(report class)

This value is a record type containing the AppleTalk information from the network-overview section of the System Profile tab. Here is a sample return value:

{AppleTalk installed:true, AppleTalk state:true, AppleTalk

version:"60", default AppleTalk zone:"Not available", active network

ports:"Ethernet built-in LocalTalk (printer) built-in", AppleTalk network:"0",

AppleTalk node:"123", AppleTalk address:"08.00.07.00.00.00", AppleTalk

router:"<not available>", AppleTalk

info:true}
AppleTalk installed (boolean)(report class)

This property returns a subset of the AppleTalk info property value. See AppleTalk info for a sample return value.

AppleTalk state (boolean)(report class)

This property returns a subset of the AppleTalk info property value. See AppleTalk info for a sample return value.

Apple Talk version (string)(report class)

This property returns a subset of the AppleTalk info property value. See AppleTalk info for a sample return value.

file sharing (boolean)(report class)

This is a true/false value indicating whether file sharing is started in the File Sharing control panel.

default AppleTalk zone (string)(report class)

This property returns a subset of the AppleTalk info property value. See AppleTalk info for a sample return value.

active network ports (string)(report class)

This property returns a subset of the AppleTalk info property value. See AppleTalk info for a sample return value.

AppleTalk network (string)(report class)

This property returns a subset of the AppleTalk info property value. See AppleTalk info for a sample return value.

AppleTalk node (string)(report class)

This property returns a subset of the AppleTalk info property value. See AppleTalk info for a sample return value.

AppleTalk address (string)(report class)

This property returns a subset of the AppleTalk info property value. See AppleTalk info for a sample return value.

AppleTalk router (string)(report class)

This property returns a subset of the AppleTalk info property value. See AppleTalk info for a sample return value.

TCPIP info (record)(report class)

This property returns a record type containing the TCP/IP data for the machine, such as TCP/IP address, version, and subnet mask. The return value looks like:

{TCPIP installed:true, TCPIP status:true, TCPIP version:"2.6.1", 

web sharing:false, multihoming:false, TCPIP netmask:"255.255.0.0", 

TCPIP address:"192.168.0.3", TCPIP gateway:"192.168.0.1", TCPIP domain:"", 

TCPIP nameserver:"192.168.0.1", TCPIP info:true}

The data is derived from the network overview section of the System profile tab.

TCPIP installed (boolean)(report class)

This property returns a subset of the TCPIP info property value. If TCP/IP is not installed then this property returns false.

TCPIP status (boolean)(report class), TCPIP version (string)(report class), multihoming (boolean)(report class)

These properties return a subset of the TCPIP info property value. See TCPIP info.

web sharing (boolean)(report class)

This property returns a subset of the TCPIP info property value. It is true if web sharing has been started in the Web Sharing control panel.

TCPIP netmask (string)(report class)

This property returns a subset of the TCPIP info property value. It returns a string such as "255.255.255.0." See TCPIP info.

TCPIP address (string)(report class)

This property returns a subset of the TCPIP info property value. It returns a string such as "172.128.0.1." See TCPIP info.

TCPIP gateway (string)(report class), TCPIP domain (string)(report class), TCPIP nameserver (string)(report class)

These properties return a subset of the TCPIP info property value. You can also find this information in the TCPIP control panel. See TCPIP info.

production info (record)(report class)

This property returns a record type that contains any production information on the machine, such as it serial number. A sample return value is:

{ROM revision:"$77D.28F1", boot ROM version:"Not available", boot ROM file 

version:"Not available", serial number:"Not applicable", software bundle 

number:"Not applicable", sales order number:"Not applicable", production 

info:true}

The following six properties are subsets of the production info value:

ROM revision (string)(report class)
boot ROM version (string)(report class)
boot ROM file version (string)(report class)
serial number (string)(report class)
software bundle number (string)(report class)
sales order number (string)(report class)
not applicable (string)(report class)

This returns the string "not applicable" if the machine is using a U.S. version of ASP. Otherwise it returns the translated version of "not applicable."

not available (string)(report class)

This returns the string "not available" if the machine is using a U.S. version of ASP. Otherwise it returns the translated version of "not available."

monitors (string)(report class)

This property returns the number of monitors that are connected to the machine.

report

This class represents an Apple System Profiler report. These reports assemble all or a subset of system information as either an ASP document or text file. Most of the report object's properties (it has no elements) are shared with the application object; those that are not shared are defined in the upcoming section. See the application class discussion for the definitions of most of the report class's properties. The following are report properties:

name (international text; read-only)

This property returns the report name as a string.

id (integer; read-only)

Every report has a unique id that looks like 182306468. You can get the ID of the frontmost report with code such as:

tell app "Apple System Profiler" to get id of report 1

If you set this value to a variable you can then refer to the report by its ID:

report ID 182306468
index (integer; read-only)

Open ASP reports can be identified with a 1-based index: report 1 for the first report that is created, report 2 for the second, etc. You can initially get the ID of a report with the code:

set myid to id of report 1
report contents (list of constants)

report contents is a list containing any of the following constants:

all
network overview
applications
printing overview
control panels
production information
devices and volumes
software overview
extensions
system folders
hardware overview
system profile
memory overview

This is a list of the type of data that the report contains. You can also use this property when you make a new ASP report; see the make command description in this chapter. The system profile category constitutes the software overview, memory overview, hardware overview, network overview, printing overview, and production information categories.

report text (string; read-only)

This property returns a large string of tab-delimited values if the report is extensive in its coverage. Its return value might be useful if you wanted to save the string to a file and then import it into a database file.

window class

This is an ASP window object that has the typical properties of a Mac window.

bounds (bounding rectangle)

This returns the boundary rectangle for the window as a list of integers, such as {50, 50, 594, 764}.

closeable (boolean; read-only)

This returns true or false depending on whether the window has a close box.

titled (boolean; read-only )

This is a true/false value depending on whether the window has a title bar.

name (international text; read-only)

This property returns the window's title, which could be useful when you try to identify a particular ASP report.

modal (boolean; read-only )

This returns a true/false value indicating whether the window is modal or not. Since most ASP windows are document windows (you can move them around and access other windows behind the document window), this property often returns false.

resizable (boolean; read-only)

This returns a true/false value indicating whether the window can be resized by dragging its corners.

zoomable (boolean; read-only)

This returns a true/false value indicating whether the window has a zoom box in its upper right-hand corner.

zoomed (boolean)

You can use this property to increase or decrease an ASP-report window size:

set zoomed of window 1 to true.

Examples

This script gathers important system information on the local machine and displays the dialog shown in Figure 11-2:

Figure 11-2. The Apple System Profiler Example dialog box
figs/ascr_1102.gif
try -- trap any errors caused by running ASP

   tell application "Apple System Profiler"

      launch -- run the app but don't bring it to the front

      set sys to system version -- a string like "9.04"

      set startdisk to StartupDiskName

      set ram to physical RAM size -- how much RAM does the machine have?

      set megh to rated speed -- how fast the machine is in megahertz

      set cpu to processor type -- an example is "PowerPC G3 400"

      (* Assemble a message to the user in the sysmessage variable *)

      set sysmessage to return & "The system version is : " & sys &¬ 

      return

      set sysmessage to sysmessage & "Startup disk name: " & startdisk¬

      & return

      set sysmessage to sysmessage & "Amount of RAM: " & ram & return

      set sysmessage to sysmessage & "CPU speed: " & megh & return

      set sysmessage to sysmessage & "CPU type: " & cpu & return

      display dialog sysmessage

   end tell

on error errMessage

   display dialog "Opening ASP caused this error: " & errMessage



end try
    Team LiB   Previous Section   Next Section