Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

urello

macrumors newbie
Original poster
Feb 28, 2014
7
0
Hello,

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)
How can one fix this? Is it possible to do this in pure AS without invoking shell?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.