• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Return 'do shell script' as an array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Return 'do shell script' as an array


  • Subject: Return 'do shell script' as an array
  • From: Jeff Dyck <email@hidden>
  • Date: Fri, 27 Aug 2010 09:19:36 -0700

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


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Xcode 4 and Examples
  • Next by Date: Re: NSDate
  • Previous by thread: Re: Xcode 4 and Examples
  • Next by thread: Re: NSDate
  • Index(es):
    • Date
    • Thread