我如何阅读用户在pass.txt中定义的文本
这是我到目前为止测试它你必须在桌面上创建一个名为test
的文件夹但是我打赌你们大多数人都可以想出来
set choice to the button returned of (display dialog "Login or Signup" buttons {"Quit", "Signup", "Login"} default button "Login")
if choice is "Signup" then
set username to the text returned of (display dialog "Enter Desired Username" default answer "")
do shell script "mkdir $HOME/Desktop/test/" & username
do shell script "echo " & username & " > ~/desktop/test/" & username & "/username.txt"
set pass to the text returned of (display dialog "Enter Password" default answer "")
set input to pass
do shell script "echo " & pass & " > ~/desktop/test/" & username & "/pass.txt"
else if choice is "Login" then
set username to the text returned of (display dialog "Enter Username" default answer "")
set y to username
set z to "pass.txt"
set x to "/Desktop/test/" & y
words of {(read (POSIX file x) & "/pass.txt") as «class utf8»} contains pass -- true
set pass to the text returned of (display dialog "Enter Password" default answer "")
else
return 0
end if
答案 0 :(得分:1)
括号未正确设置。试试这个:
read POSIX file (x & "/pass.txt")
或
do shell script "cat " & quoted form of (POSIX path of (path to desktop) & "test/" & username & "/pass.txt")
无论如何,脚本中还有许多其他问题。只是一些提示,使用......
- 引用形式的
- mkdir
- 密码输入的with hidden answer
选项