title: lang/expect: execute a different binary if the prior one doesn't exist
body: <p>I'm using <a href="http://ports.su/lang/expect" rel="nofollow noreferrer">lang/expect</a>, and for the <code>spawn</code> command, I'd like to conditionally execute one of two different binaries, e.g., depending on whether or not <code>qemu-system-x86_64</code> exists, I'd like to either do a <code>spawn qemu-system-x86_64 …</code>, or, if it doesn't exist, simply call <code>spawn kvm …</code> instead.  (The arguments to both <code>kvm</code> and <code>qemu-…</code> commands are the same, only the name of the executable itself is different.)</p>
  
  <p>How do I do it within the Expect language?</p>
  
  <p>Per the <a href="http://mdoc.su/f/expect.1" rel="nofollow noreferrer">documentation of how the <code>spawn</code> directive within <code>expect</code></a> works (it internally does a <a href="http://mdoc.su/f/fork.2" rel="nofollow noreferrer"><code>fork</code></a>), one "recommended" approach would be to see if the execution fails by looking at what the spawned process prints to its terminal; however, that would be suboptimal, as I simply want to test whether the given executable exists (in <code>$PATH</code>).</p>