title: Bash - create multiple virtual guests in one loop
body: <p>I'm working on a bash script (I just started learning bash) that involves creating virtual guests on a remote server. I do this by SSH'ing from server A to B and execute 2 different commands:</p>
  
  <pre><code># create the images
  $(ssh -n john@serverB.net "fallocate -l ${imgsize} /home/john/images/${imgname}") 
  </code></pre>
  
  <p>and</p>
  
  <pre><code># create the virtual machine
  $(ssh -n john@serverB.net virt-install --bunch of options) 
  </code></pre>
  
  <p>It is possible that these sets of commands have to be executed twice (if there need to be 2 virtual guests created) in a loop. When the second command is being run for the second time I sometimes get this error:</p>
  
  <pre><code>Domain installation still in progress.
  </code></pre>
  
  <p>This means I have to wait until the previous virtual guest is completed. How would I be able to do these operations in one loop? Can I run them asynchronously? Can I use threads? Or is there another way?</p>
  
  <p>I have heard about the 'wait' command, but is that safe to use?</p>