문제

How would i read the text the user defined in pass.txt

This is What I have so far to test it you must make a folder on your desktop called test

but I bet most of you could have figured that out

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
도움이 되었습니까?

해결책

The brackets are not set correctly. Try this:

read POSIX file (x & "/pass.txt")

or

do shell script "cat " & quoted form of (POSIX path of (path to desktop) & "test/" & username & "/pass.txt")

There are many other issues in the script anyway. Just a few tips, use...

-quoted form of pathes

-the -p option for mkdir

-the with hidden answer option for password entry

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top