简体   繁体   中英

Do shell script in Applescript?

I'm trying to understand some lines of code. I think that this code checks if the password is correct or not.

Am I right?

do shell script "dscl . -passwd /Users/" & username & " " & pw & " llama"
do shell script "dscl . -passwd /Users/" & username & " lalala " & pw & ""

What is the "lalala"-parameter?

I do not know what it does stand for and what does it means?

The & operator in AppleScript is used for string-concatenation. So if we look at your script as if those variables were already filled in, we would see:

dscl . -passwd /Users/TEST_USER TEST_PASS lalala
dscl . -passwd /Users/TEST_USER lalala TEST_PASS

Now you can see what the script is really doing, which is invoking the dscl command. This is doing 2 things:

  1. Changing the TEST_USER 's password from TEST_PASS to lalala
  2. Changing the TEST_USER 's password from lalala to an empty string.

The lalala isn't particularly significant, it's merely being used a placeholder password to change from the original TEST_PASS to eventually an empty string.

Without seeing the rest of the script, I'd guess that this AppleScript is being used as a way to clear out or reset a user's password, given the username and their original password.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM