title: Linux screen command automation
body: <p>I am using the Linux <code>screen</code> command to run different directory files one by one. I have 33 VM folders, and each folder contains images to execute.</p>
  
  <pre><code>Root directory      = /home/root/
  VM folder available = /home/root/vm1,vm2,vm3...vm32
  </code></pre>
  
  <p>I have to run all VMs at the same time. For that reason I am using the <code>screen</code> command. Each <code>screen</code> command will execute on VM. It should traverse all 33 VM folders and execute all 33 VM images at the same time.</p>
  
  <pre><code>Ctrl + A, C = new screen
  </code></pre>
  
  <p>Following is my code:</p>
  
  <pre><code>     for (( i=0; i&lt;=33; i++))
          do
          screen
          ls
          vm1 vm2 vm3 vm4 ....vm33
          cd vm1
          ls
          qemu-system-x86_64 -kernel image -hda core-image-full-cmdline-qemux86-64.ext3 -smp 4 -m 512 -nographic --append \
      "root=/dev/hda console=ttyS0 rw mem=512M oprofile.timer=1"
          cd ..
          screen
          qemu-system-x86_64 -kernel image -hda core-image-full-cmdline-qemux86-64.ext3 -smp 4 -m 512 -nographic --append \
  "root=/dev/hda console=ttyS0 rw mem=512M oprofile.timer=1"
          cd ..
          .
          .
          .
          done
  </code></pre>
  
  <p><a href="https://en.wikipedia.org/wiki/QEMU" rel="nofollow noreferrer">QEMU</a> exits as soon as it is launched, and <code>screen</code> with it. How can I fix this issue?</p>