Fetch values from plist file on Linux

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite
1












I have bash script which was written for OS X and now ported to Linux. I don't have access to the Linux box. The bash script would read values from plist files using the defaults read and PlistBuddy command available on OS X.



Since the Linux machine doesn't have these commands, I'm looking for workarounds. Is there library/script (Perl preferably) that helps user fetch values from plist files for a given key on a Linux machine?



I tried using sed/awk, but the output isn't reliable. I've come across scripts like plutil.pl that convert a plist file to other formats.



I have installed a Virtual machine running Ubuntu on my Mac so that I can test my changes before deploying to the actual Linux box.










share|improve this question























  • Which programs on Linux do you expect to make use of plists? I haven't come across any in the last 12 years of Linux use on a daily basis.
    – tink
    Oct 30 '12 at 3:09










  • The linux machine hosts folders that have plist files in them. No programs on the Linux machine are going to use them.But I need to create a report on those folders and hence need to find a way to read values from the plist file on the Linux env.
    – smokinguns
    Oct 30 '12 at 3:19















up vote
4
down vote

favorite
1












I have bash script which was written for OS X and now ported to Linux. I don't have access to the Linux box. The bash script would read values from plist files using the defaults read and PlistBuddy command available on OS X.



Since the Linux machine doesn't have these commands, I'm looking for workarounds. Is there library/script (Perl preferably) that helps user fetch values from plist files for a given key on a Linux machine?



I tried using sed/awk, but the output isn't reliable. I've come across scripts like plutil.pl that convert a plist file to other formats.



I have installed a Virtual machine running Ubuntu on my Mac so that I can test my changes before deploying to the actual Linux box.










share|improve this question























  • Which programs on Linux do you expect to make use of plists? I haven't come across any in the last 12 years of Linux use on a daily basis.
    – tink
    Oct 30 '12 at 3:09










  • The linux machine hosts folders that have plist files in them. No programs on the Linux machine are going to use them.But I need to create a report on those folders and hence need to find a way to read values from the plist file on the Linux env.
    – smokinguns
    Oct 30 '12 at 3:19













up vote
4
down vote

favorite
1









up vote
4
down vote

favorite
1






1





I have bash script which was written for OS X and now ported to Linux. I don't have access to the Linux box. The bash script would read values from plist files using the defaults read and PlistBuddy command available on OS X.



Since the Linux machine doesn't have these commands, I'm looking for workarounds. Is there library/script (Perl preferably) that helps user fetch values from plist files for a given key on a Linux machine?



I tried using sed/awk, but the output isn't reliable. I've come across scripts like plutil.pl that convert a plist file to other formats.



I have installed a Virtual machine running Ubuntu on my Mac so that I can test my changes before deploying to the actual Linux box.










share|improve this question















I have bash script which was written for OS X and now ported to Linux. I don't have access to the Linux box. The bash script would read values from plist files using the defaults read and PlistBuddy command available on OS X.



Since the Linux machine doesn't have these commands, I'm looking for workarounds. Is there library/script (Perl preferably) that helps user fetch values from plist files for a given key on a Linux machine?



I tried using sed/awk, but the output isn't reliable. I've come across scripts like plutil.pl that convert a plist file to other formats.



I have installed a Virtual machine running Ubuntu on my Mac so that I can test my changes before deploying to the actual Linux box.







linux bash scripting osx perl






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 30 '12 at 22:42









Gilles

512k12010151547




512k12010151547










asked Oct 30 '12 at 2:50









smokinguns

151137




151137











  • Which programs on Linux do you expect to make use of plists? I haven't come across any in the last 12 years of Linux use on a daily basis.
    – tink
    Oct 30 '12 at 3:09










  • The linux machine hosts folders that have plist files in them. No programs on the Linux machine are going to use them.But I need to create a report on those folders and hence need to find a way to read values from the plist file on the Linux env.
    – smokinguns
    Oct 30 '12 at 3:19

















  • Which programs on Linux do you expect to make use of plists? I haven't come across any in the last 12 years of Linux use on a daily basis.
    – tink
    Oct 30 '12 at 3:09










  • The linux machine hosts folders that have plist files in them. No programs on the Linux machine are going to use them.But I need to create a report on those folders and hence need to find a way to read values from the plist file on the Linux env.
    – smokinguns
    Oct 30 '12 at 3:19
















Which programs on Linux do you expect to make use of plists? I haven't come across any in the last 12 years of Linux use on a daily basis.
– tink
Oct 30 '12 at 3:09




Which programs on Linux do you expect to make use of plists? I haven't come across any in the last 12 years of Linux use on a daily basis.
– tink
Oct 30 '12 at 3:09












The linux machine hosts folders that have plist files in them. No programs on the Linux machine are going to use them.But I need to create a report on those folders and hence need to find a way to read values from the plist file on the Linux env.
– smokinguns
Oct 30 '12 at 3:19





The linux machine hosts folders that have plist files in them. No programs on the Linux machine are going to use them.But I need to create a report on those folders and hence need to find a way to read values from the plist file on the Linux env.
– smokinguns
Oct 30 '12 at 3:19











2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










Since .plist files are already XML (or can be easily converted) you just need something to decode the XML.



For that use xml2:



$ cat com.apple.systemsound.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.sound.beep.volume</key>
<real>1</real>
</dict>
</plist>
$ xml2 < com.apple.systemsound.plist
/plist/@version=1.0
/plist/dict/key=com.apple.sound.beep.volume
/plist/dict/real=1
$


You should be able to figure out the rest.



Or for Perl, use XML::Simple; (see perldoc for more) to put the XML data structure into a hash.






share|improve this answer



























    up vote
    5
    down vote













    libplist seems to meet your requirements.
    There is a Ubuntu package name "libplist-utils" that you could reference in your script:




    Description-en: Apple property list converter
    This package containt tools to convert Apple property list files from binary
    to XML and vice-versa. It's part of the libimobiledevice stack, providing
    access to iDevices (iPod, iPhone, iPad ...).




    Homepage: http://www.libimobiledevice.org/



    Install command:



    apt-get install libplist-utils


    Usage example:



    plistutil -i Info.plist





    share|improve this answer






















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f53275%2ffetch-values-from-plist-file-on-linux%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote



      accepted










      Since .plist files are already XML (or can be easily converted) you just need something to decode the XML.



      For that use xml2:



      $ cat com.apple.systemsound.plist
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
      <plist version="1.0">
      <dict>
      <key>com.apple.sound.beep.volume</key>
      <real>1</real>
      </dict>
      </plist>
      $ xml2 < com.apple.systemsound.plist
      /plist/@version=1.0
      /plist/dict/key=com.apple.sound.beep.volume
      /plist/dict/real=1
      $


      You should be able to figure out the rest.



      Or for Perl, use XML::Simple; (see perldoc for more) to put the XML data structure into a hash.






      share|improve this answer
























        up vote
        1
        down vote



        accepted










        Since .plist files are already XML (or can be easily converted) you just need something to decode the XML.



        For that use xml2:



        $ cat com.apple.systemsound.plist
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
        <dict>
        <key>com.apple.sound.beep.volume</key>
        <real>1</real>
        </dict>
        </plist>
        $ xml2 < com.apple.systemsound.plist
        /plist/@version=1.0
        /plist/dict/key=com.apple.sound.beep.volume
        /plist/dict/real=1
        $


        You should be able to figure out the rest.



        Or for Perl, use XML::Simple; (see perldoc for more) to put the XML data structure into a hash.






        share|improve this answer






















          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          Since .plist files are already XML (or can be easily converted) you just need something to decode the XML.



          For that use xml2:



          $ cat com.apple.systemsound.plist
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
          <plist version="1.0">
          <dict>
          <key>com.apple.sound.beep.volume</key>
          <real>1</real>
          </dict>
          </plist>
          $ xml2 < com.apple.systemsound.plist
          /plist/@version=1.0
          /plist/dict/key=com.apple.sound.beep.volume
          /plist/dict/real=1
          $


          You should be able to figure out the rest.



          Or for Perl, use XML::Simple; (see perldoc for more) to put the XML data structure into a hash.






          share|improve this answer












          Since .plist files are already XML (or can be easily converted) you just need something to decode the XML.



          For that use xml2:



          $ cat com.apple.systemsound.plist
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
          <plist version="1.0">
          <dict>
          <key>com.apple.sound.beep.volume</key>
          <real>1</real>
          </dict>
          </plist>
          $ xml2 < com.apple.systemsound.plist
          /plist/@version=1.0
          /plist/dict/key=com.apple.sound.beep.volume
          /plist/dict/real=1
          $


          You should be able to figure out the rest.



          Or for Perl, use XML::Simple; (see perldoc for more) to put the XML data structure into a hash.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 30 '12 at 19:05









          bahamat

          23.6k14590




          23.6k14590






















              up vote
              5
              down vote













              libplist seems to meet your requirements.
              There is a Ubuntu package name "libplist-utils" that you could reference in your script:




              Description-en: Apple property list converter
              This package containt tools to convert Apple property list files from binary
              to XML and vice-versa. It's part of the libimobiledevice stack, providing
              access to iDevices (iPod, iPhone, iPad ...).




              Homepage: http://www.libimobiledevice.org/



              Install command:



              apt-get install libplist-utils


              Usage example:



              plistutil -i Info.plist





              share|improve this answer


























                up vote
                5
                down vote













                libplist seems to meet your requirements.
                There is a Ubuntu package name "libplist-utils" that you could reference in your script:




                Description-en: Apple property list converter
                This package containt tools to convert Apple property list files from binary
                to XML and vice-versa. It's part of the libimobiledevice stack, providing
                access to iDevices (iPod, iPhone, iPad ...).




                Homepage: http://www.libimobiledevice.org/



                Install command:



                apt-get install libplist-utils


                Usage example:



                plistutil -i Info.plist





                share|improve this answer
























                  up vote
                  5
                  down vote










                  up vote
                  5
                  down vote









                  libplist seems to meet your requirements.
                  There is a Ubuntu package name "libplist-utils" that you could reference in your script:




                  Description-en: Apple property list converter
                  This package containt tools to convert Apple property list files from binary
                  to XML and vice-versa. It's part of the libimobiledevice stack, providing
                  access to iDevices (iPod, iPhone, iPad ...).




                  Homepage: http://www.libimobiledevice.org/



                  Install command:



                  apt-get install libplist-utils


                  Usage example:



                  plistutil -i Info.plist





                  share|improve this answer














                  libplist seems to meet your requirements.
                  There is a Ubuntu package name "libplist-utils" that you could reference in your script:




                  Description-en: Apple property list converter
                  This package containt tools to convert Apple property list files from binary
                  to XML and vice-versa. It's part of the libimobiledevice stack, providing
                  access to iDevices (iPod, iPhone, iPad ...).




                  Homepage: http://www.libimobiledevice.org/



                  Install command:



                  apt-get install libplist-utils


                  Usage example:



                  plistutil -i Info.plist






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Sep 28 at 9:49









                  martin

                  1032




                  1032










                  answered Oct 30 '12 at 15:27









                  BorisHajduk

                  22918




                  22918



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f53275%2ffetch-values-from-plist-file-on-linux%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay