+ Post New Thread
Results 1 to 3 of 3
Mac Thread, Shell script variable from .plist? in Technical; Trying to automatically create a .plist to setup a system profile for 802.1x or at the very least grab these ...
  1. #1

    Join Date
    May 2008
    Posts
    213
    Thank Post
    2
    Thanked 27 Times in 27 Posts
    Rep Power
    18

    Shell script variable from .plist?

    Trying to automatically create a .plist to setup a system profile for 802.1x or at the very least grab these strings from a .plist - the command is working from command line but i'd like to store it in a variable to create my plist later...

    Whats wrong with:

    Code:
    machineid='/usr/libexec/plistbuddy -c print :AD\ Computer\ Kerberos\ ID /Library/Preferences/DirectoryService/ActiveDirectory.plist'
    This just gives me the command as text so i'm assuming the syntax is wrong to call plistbuddy? Can I set this variable via plistbuddy somehow?

  2. #2

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,824
    Thank Post
    372
    Thanked 544 Times in 507 Posts
    Rep Power
    184
    Try putting it into "'s Otherwise you're asking it to print the entire line aren't you?


    Code:
    -c "print 'AD\ Computer\ Kerberos\ ID'" /Library/Preferences/DirectoryService/ActiveDirectory.plist'
    Try:

    Code:
    usr/libexec/Plistbuddy \
    -c "Print 'AD Computer Password'" \
    /Library/Preferences/DirectoryService/ActiveDirectory.plist
    Too if above doesn't work

    Steve

  3. #3

    Join Date
    May 2008
    Posts
    213
    Thank Post
    2
    Thanked 27 Times in 27 Posts
    Rep Power
    18
    Arrr just realised I was using apostrophes and not 'back quotes', my troubleshooting script:
    Code:
    #!/bin/bash
    machineid=`/usr/libexec/plistbuddy -c 'print :AD\ Computer\ Kerberos\ ID' '/Library/Preferences/DirectoryService/ActiveDirectory.plist'`
    echo "$machineid"



SHARE:
+ Post New Thread

Similar Threads

  1. Run Shell Script BEFORE logon
    By mbrunt in forum Mac
    Replies: 5
    Last Post: 29th April 2014, 08:27 PM
  2. Pass a program variable in VB Script?
    By cookie_monster in forum Coding
    Replies: 21
    Last Post: 22nd April 2013, 09:04 AM
  3. Missing .plist file
    By HallX in forum Mac
    Replies: 7
    Last Post: 22nd July 2010, 01:11 PM
  4. Replies: 16
    Last Post: 25th February 2010, 09:59 AM
  5. Replies: 1
    Last Post: 9th September 2009, 08:22 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •