Parsing system_profiler infos?

How to retrieve (parsing) the information retrieved by the Terminal command:
“system_profiler SPStorageDataType” ?
Thanks

The returned information is a set of strings…

So pass the command using the shell and display the result in a DesktopTextArea.

Information for the Shell.

You even have an example to do that (you only have to change the command).

But i want to be able to choose the fields to display in my application.

And so what ?

You know what you want to display, so iterate the text until you reach what you want…

Search from the returned data (example for a internal SSD partition:

Storage:


    Data:

      Free: 104,75 GB (104 748 621 824 bytes)
      Capacity: 494,38 GB (494 384 795 648 bytes)
      Mount Point: /System/Volumes/Data
      File System: APFS
      Writable: Yes
      Ignore Ownership: No
      BSD Name: disk3s5
      Volume UUID: 1A6B77C3-8966-48A8-8DBD-7F748A9CC1BE
      Physical Drive:
          Device Name: APPLE SSD AP0512Q
          Media Name: AppleAPFSMedia
          Medium Type: SSD
          Protocol: Apple Fabric
          Internal: Yes
          Partition Map Type: Unknown
          S.M.A.R.T. Status: Verified

Search in the documentation the String related isntructions.

Unless this is your first day (week ? moth ?) with Xojo and then you are asking the code to do that, with the documentation you will be able to do what you want.

Something like IndexOf will return where in the passed string start the string you’re seeking:
https://documentation.xojo.com/api/data_types/string.html#string-indexof

You may use another output format for selective parsing.
Look at man system_profiler and use e.g.

system_profiler -xml SPStorageDataType
system_profiler -json SPStorageDataType

Nice.

But if the op do not know how to read xml…

You can use:

system_profiler -xml SPStorageDataType >profile.xml

to generate an xml file and start your xml parsing from there…