Reputation: 15
I'm just messing around with apple to script to joke with my friends. I made this simple terminal command to look like their computer is getting hacked (they scare easy). I was going to compile it into an application in apple script, but when I compile it, I keep receive a syntax error. I have tried fixing it, but to no avail. I'm just learning apple script, so this is probably a dumb rookie question. Thanks! ~Cole
Here is the script:
tell application "Terminal"
do script "while (true) do echo -n "Error: System Breach Detected 190721064281 killing proccesses. 12060219682197312-90785236412412001-612073412-712481243261=1123-0914712-1209412107381\][12389138719 End."; done"
activate
end tell
Upvotes: 0
Views: 154
Reputation: 126088
You're trying to nest a double-quoted string ("Error: System Breach...
) inside another double-quoted string ("while (true) do...
), but quotes don't nest. When AppleScript sees "while (true) do echo -n "Error
, it thinks it's seeing a double-quoted string followed by the word Error
, which doesn't make any sense.
To fix this, you can escape the inner double-quotes with backslashes (\
) -- AppleScript will remove the escapes as it parses the string, so they won't get passed to the shell and confuse it. But there's another problem: you also have a stray escape (backslash) in the middle of the string, and that'll also confuse AppleScript. In order to make that work, you actually need to escape the escape (\\
). Here's the result of adding the necessary escapes:
tell application "Terminal"
do script "while (true) do echo -n \"Error: System Breach Detected 190721064281 killing proccesses. 12060219682197312-90785236412412001-612073412-712481243261=1123-0914712-1209412107381\\][12389138719 End.\"; done"
activate
end tell
Upvotes: 1