How can we send user input taken from UI to commandline and run a command using objective c -
i want reset mac osx password , want gui. know in terminal have run following command.
aug4-2:~ root# passwd changing password root new password: retype new password:
for want provide user interface, user can reset user password. need use nstask , nspipe task. if 1 have code snippet please post here
try using apple script.
tell application "system events" activate display dialog "please enter old password:" default answer "" title "password reset" hidden answer set pswd0 text returned of result end tell tell application "system events" activate display dialog "please enter new password:" default answer "" title "password reset" hidden answer set pswd1 text returned of result end tell tell application "system events" activate display dialog "please re-enter new password:" default answer "" title "password reset" hidden answer set pswd2 text returned of result end tell if pswd1 = pswd2 if pswd1 = pswd0 display dialog "both passwords entered same" title "password reset" return end if else display dialog "re entered password different" title "password reset" return end if try shell script "dscl . -passwd /users/$user " & quoted form of pswd0 & " " & quoted form of pswd1 & " " on error errmsg number errornumber if 10 = errornumber display dialog "old password entered incorrect" title "password reset" return else if 90 = errornumber display dialog "new password not meeting password policy requirements, password length small" title "password reset" return else if 93 = errornumber display dialog "new password not meeting password policy requirements ,it should consist of atleast 1 numeric character" title "password reset" return end if end if end if return end try display dialog "password changed succesfully" title "password reset" return true
Comments
Post a Comment