title: Applescript returns "The command exited with a non-zero status" on do shell script
body: <p>I'm working with an Applescript that I'm trying to make, after it does a command to check back results of a command, but when I execute it, it prompts a message (in AppleScript Editor); <code>Expected expression but found “error”.</code>.</p>
  
  <p>How can I fallback and check if the command is same as <code>The command exited with a non-zero status.</code> so I can do something else if it's the same as the error message?</p>
  
  <pre><code>do shell script "echo \"stats\" | nc localhost 11211" password "~password~" with administrator privileges
  
  if error = "The command exited with a non-zero status." then
      display dialog "Returned zero"
  else if result = "The command exited with a non-zero status." then
      display dialog "Returned zero"
  else if result = "" then
      do shell script "memcached -d -l 127.0.0.1 -p 11211 -m 64"
      display dialog "Memcached Started"
  else
      do shell script "killall memcached" with administrator privileges
      display dialog "Memcached Stopped"
  end if
  </code></pre>
  
  <p><strong>EDIT:</strong> Updated version</p>
  
  <pre><code>set error to do shell script "echo \"stats\" | nc localhost 11211" password "~password~" with administrator privileges
  
  if error = "The command exited with a non-zero status." then
      do shell script "memcached -d -l 127.0.0.1 -p 11211 -m 64"
      display dialog "Memcached Started"
  else
      do shell script "killall memcached" with administrator privileges
      display dialog "Memcached Stopped"
  end if
  </code></pre>