Hello,
I recently posted a plea for help on getting the MAC address of the wireless card, I’m very new to applescript and have only used it to move folders, create alias’s etc. (after using custom Apple System Restores)
I’ve started reading the old AppleScript Guide (the one from '99) but so far I don’t see any good examples of using the “Dictionary’s”.
Basically I need to open up Apple System profiler and have it print to a text file the Wireless Crad info (just the MAC address). From what I see in the Dictionary it seems very possible to get the Network info and print it out to a text file, so hopefully someone can push me in the correct direction
Example:
tell application “Apple System Profiler”
activate
AppleTalk address
— this will show the results of the MAC addys’ on both wireless and wired
How would I print this to a simple text file?
I’m not sure how you want the text to look. I don’t have a wireless card in either of my machines, but I think this would save both your addresses in OS 9.2.2:
tell application "Apple System Profiler"
set ATaddresses to AppleTalk address
end tell
-- Get the addresses in the list into a single, comma-delimited string with a header
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ", "
set fileText to "AppleTalk address(es): " & ATaddresses
set AppleScript's txt item delimiters to astid
-- Save the string to a file on the desktop
set fRef to (open for access file ((path to desktop as string) & "AppleTalk address(es)") with write permission)
try
set eof fRef to 0
write fileText to fRef
end try
close access fRef
But the subject line of your query ends with a strangulated “OS8 throug”. The version of Apple System Profiler that comes with OS 8.6 doesn’t have an ‘AppleTalk address’ property, so you’d need something like this if you wanted a script that worked on both systems:
-- The path for a report file
set reportPath to (path to desktop as string) & "Network Overview report"
-- Get an ASP Network Overview report and save it
tell application "Apple System Profiler"
activate
set aReport to (make new report at end with properties {report contents:network overview})
save aReport in file reportPath
close front window
end tell
-- Read the report file and extract the hardware address(es)
-- I don't know how it looks with more than one address, so this may need further editing
set fileText to read file reportPath from 1
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "Hardware Address:" & tab
set fileText to "AppleTalk address(es): " & paragraph 1 of text item 2 of fileText
set AppleScript's text item delimiters to astid
-- Save the edited text to a new file that has no text formatting
set fRef to (open for access file ((path to desktop as string) & "AppleTalk address(es)") with write permission)
try
set eof fRef to 0
write fileText to fRef
on error
end try
close access fRef
-- Delete the old report file
tell application "Finder" to delete file reportPath