Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to delete an application password. I'm using the security delete-generic-password command. When I execute it via terminal, everything works fine – it does delete the password.

When I include the same command in a shell script, and then execute it via Xcode, it does not delete the password. I guess the problem is that the security command can't get the root password.

I'm deleting it in an uninstaller, so before I execute anything, I'm asking for the root password. After that, I'm calling this script through the Xcode project. Since I already have the root password, I execute command with sudo as follows:

sudo security delete-generic-password password_name "/Library/Keychains/System.keychain"

I hope sudo does get the root password internally, as I'm already authenticating before executing anything in my uninstaller.

share|improve this question
What's the return code of this command? – Daniel Beck Feb 8 '12 at 6:35
By the way, you can edit your posts at any time to provide additional information. There is no need to delete previously posted questions and post essentially the same thing again. – Daniel Beck Feb 8 '12 at 8:48
I have identified the problem . the thing is when we execute command via terminal it asks for password and after we enter and if its correct it deletes the keychain. But if we use it in some script and try to execute it via Xcode project their is no UI that essential asks for password so it does not get password thats why it was not able to delete it . now i all want to know is how can we put up UI asking for password and then passing that password to the security command ... – chitnisprasanna Feb 16 '12 at 6:26
and when i checked in the Console it was giving this error no tty present and no askpass program specified ; TTY=unknown ; PWD=/ ; USER=root ;.. – chitnisprasanna Feb 16 '12 at 6:34
Then something's wrong with the environment in which you execute this code, and which you haven't explained in detail. If you want help, explain in detail how other users can reproduce the problem from scratch and without having ever written an OS X installer or uninstaller. Edit your question and add relevant information. – Daniel Beck Feb 20 '12 at 6:44

You must log in to answer this question.

Browse other questions tagged .