System Profiler

Hello!

I am developing a program which gathers information about the computer and then stores it in an XML file for future reference. I have written versions of this program for other platforms already and now I want to create a Mac OS version as well. Though I am an avid Mac user (fairly new to OS X however) I have never programmed for them before, so I’m looking for help here.

Now seeing as the System Profiler has the info I’m looking for readily available and even allows for saving as an XML file it looks like this version should be really easy to write, and reading the System Profiler help files it seems that automating the process of creating such a document can be done easily in Applescript, but since I’ve never programmed with Applescript before I can’t quite figure out how. Does anyone here have any pointers? What I want the script to do is simply to create a new System Profiler document. I did look through the archives for threads concerning this but despite finding a number with promising titles none of them really answered this particular question.

Any help appreciated.

AppleScript: 1.10
Operating System: Mac OS X (10.4)

Getting the Profiler data as a variable is easy, but the xml file will require a program or a system (Tiger?) that can handle the xml data. This will put the data into a text file for an example of what your looking at:


tell application "Apple System Profiler"
	activate --Open ASProfiler
	set this_data to (system profile) as text --Profiler Data to Text
end tell


set target_file to (((path to desktop folder) as text) & "MySysProfile") --Initiate a new file

--Write Profile Data To Text Document On Desktop
set the target_file to the target_file as text
set openTargetFile to open for access file target_file with write permission
set eof of the openTargetFile to 0
write this_data to the openTargetFile starting at eof
close access openTargetFile

SC

Just “System Profiler”, leave off the word Apple.

TextEdit will open it and iterpret the XML.

Thank you!