Hello,
In my script i get string from user and need to ensure that string contains only alphanumerical characters. There is a sample:
The error:
How can one fix this? Is it possible to do this in pure AS without invoking shell?
In my script i get string from user and need to ensure that string contains only alphanumerical characters. There is a sample:
Code:
#!/bin/bash
REGEX="^[[:alnum:]]*$"
osascript <<EOF
tell application "SystemUIServer"
repeat
set username to text returned of (display dialog "Enter your name" with icon caution default answer "" buttons{"Continue"})
if text returned of (do shell script "if ! [[ " & quoted form of username & " =~ $REGEX ]]; then echo \"notok\"; fi") as text is equal to "notok" then
display alert "WRONG CHARACTER"
else
exit repeat
end if
end repeat
end tell
EOF
The error:
Code:
execution error: Can▒t make text returned of "notok" into type text. (-1700)