title: GDB: Check if target extended-remote localhost:3333 was successful in command file
body: <p>I've got a simple gdb command file:</p>
  
  <pre><code>set pagination off
  set logging file ../log/buildlog.txt
  set logging on
  info breakpoints
  set remotetimeout 3
  target extended-remote localhost:3333 arg1
  load
  monitor reset
  set logging off
  quit
  </code></pre>
  
  <p>I want to add something like this:</p>
  
  <pre><code>set pagination off
  set logging file ../log/buildlog.txt
  set logging on
  info breakpoints
  set remotetimeout 3
  if ("target extended-remote localhost:3333 arg1")
      echo Succeeded
  else
      quit
  end
  load
  monitor reset
  set logging off
  quit
  </code></pre>
  
  <p>I tried doing this via bash like so:</p>
  
  <pre><code>if [ $(arm-none-eabi-gdb -x "../build/gdbcfg.gdb" --args $1) ];then
      echo "Upload success"
  else
      echo "Failed to upload. Is openocd connected?"
      exit -1
  fi
  </code></pre>
  
  <p>But this doesn't achieve anything because I have no idea what the arm-none-eabi-gdb returns when something fails, and I can't find it in any documentation. </p>