Resolved [Applescript] Security Framework issue

Discussion in 'Mac Programming' started by dezzeus, Mar 12, 2013.

  1. dezzeus, Mar 12, 2013
    Last edited: Mar 12, 2013

    macrumors newbie

    Joined:
    Dec 9, 2012
    #1
    I was looking for running a shell command as root without asking the password to the user (except the first time), so I've decided to go through the Security Framework making a keychain to store and retrieve it in security but, as long as the Terminal prints the correct password:
    Code:
    password: "the_password"
    doing the same from within Applescript, it returns me an empty string! :confused:
    The code who give me that problem is:
    Code:
    set rootPassword to word 2 of (do shell script "security find-generic-password -gs \"my_service\" | tail -n 0")
    Obviously, the keychain is made in order to allow the security command to access everything without asking for a password. :rolleyes:

    P.S.: I've tried to remove both the tail part and the word 2 of one in the Applescript code and it prints every line except the one that I need. :(
     
  2. thread starter macrumors newbie

    Joined:
    Dec 9, 2012
    #2
    I've resolved using
    Code:
    set rootPassword to word 2 of (do shell script "security 2>&1 >/dev/null find-generic-password -gs \"my_service\"")
     

Share This Page