[英]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. AppleScript中的&
运算符用于字符串连接。 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. 现在,您可以看到脚本实际上在做什么,它正在调用dscl
命令。 This is doing 2 things: 这是在做两件事:
TEST_USER
's password from TEST_PASS
to lalala
将TEST_USER
的密码从TEST_PASS
为lalala
TEST_USER
's password from lalala
to an empty string. 将TEST_USER
的密码从lalala
更改为空字符串。 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. lalala
并不是特别重要,它只是被用作占位符密码以从原始TEST_PASS
更改为最终的空字符串。
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. 在没有看到脚本的其余部分的情况下,我猜想该AppleScript被用作清除或重置用户密码(给定用户名和原始密码)的一种方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.