bash script to run a command and take screenshot in every loop.

2010-09-24 2 min read bash Fedora Learning Linux

Couple of days back, I had posted a command to display a stop timer with bash and echo. There I had also put the following gif file:

<img class="size-medium wp-image-2555" title="bash screenshot for the script output" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/09/temp-300x170.gif" alt="bash screenshot for the script output" width="300" height="170" />

Here the tricky part was to capture the jpg&#8217;s to create the gif file.

Preparation:

  1. Rename the terminal to aka – amit-capture

  2. Execute the command once with the import command and check the output and jpg&#8217;s

  3. Change the font size to 56 or 60 and resize the terminal before executing the command.

To to this I used the import command from the loop command to capture the terminal in every step of the loop.

Here is the full command:

  <td>
    <div class="bash codecolorer">
      <span class="kw2">clear</span><br /> <br /> <span class="kw1">for</span> i <span class="kw1">in</span> <span class="sy0">`</span><span class="kw2">seq</span> <span class="nu0">100</span> <span class="re5">-1</span> <span class="nu0">90</span><span class="sy0">`</span><br /> <span class="kw1">do</span><br /> <span class="kw3">echo</span> <span class="re5">-ne</span> <span class="st0">"<span class="es2">$i</span>   \<span class="es1">\r</span>"</span><br /> <span class="kw2">sleep</span> <span class="nu0">1</span>; import <span class="re5">-window</span> <span class="st0">"aka - amit-capture"</span> <span class="re5">-resize</span> <span class="nu0">50</span><span class="sy0">%</span> <span class="re1">$i</span>.jpg<br /> <span class="kw1">done</span>
    </div>
  </td>
</tr>
1
2
3
4
5
6
7

For execution, just use history, it might be very difficult to type the full command again with small terminal and big fonts 🙂

\"Enhanced
comments powered by Disqus