Hey all, there doesn't seem to be too much activity on this list, but will try anyway...
In AppleScript Studio I have previously loaded a plist file into my app as an array using call method and "arrayWithContentsOfFile:" of class "NSArray". Once it is in AppleScript, I have been able to then parse data from it, like so:
on loadPlist() set filePath to the resource path of the main bundle & "/RestoreOptions.plist" set plistArray to call method "arrayWithContentsOfFile:" of class "NSArray" with parameter (POSIX path of filePath) end loadPlist on getEnglishList(backupDir, currentOS, adminName, adminpass)
set englishList to {} repeat with an_item in plistArray set itemLocation to an_item's Locations set itemName to an_item's english
if currentOS contains "10.4" then set originalLoc to itemLocation's |10.4| else if currentOS contains "10.5" then set originalLoc to itemLocation's |10.5| else if currentOS contains "10.6" then set originalLoc to itemLocation's |10.6| end if
set fileTest to (backupDir & "/" & originalLoc) set isDir to |isDirectory| of an_item
if isDir is true then if folderExistsAtPath(fileTest, adminName, adminpass) is true then set end of englishList to {true, itemName} end if else if itemExistsAtPath(fileTest, adminName, adminpass) is true then set end of englishList to {true, itemName} end if end if end repeat
return englishList end getEnglishList
I'm trying to write a small script now that runs a shell command via do shell script, but the command returns an xml result, and I would like to have it in the same parse-able format (array?) so that I can pull out some specific bits of data.
Unfortunately I seem to be running into issues under ASOC, to the point that I can't even use the above code anymore!?!
More specifically, I'm trying to run the system_profiler command, choosing to export as xml, and want to parse out the Network interface names (ie: en0), IPv4 Address and Subnet Mask for each network interface.
Any ideas on how to migrate this kind of stuff to the more modern ASOC code?
Thanks in advance
Jeff
|