Screenshots from the command line (FreeBSD)

vidcontrol is a nice utility that among other things allows one to capture the state of a video buffer and dump it to a file. The format of this file is specified in the man page as it is not a regular image file. For this reason one needs a specific tool to convert it to something one can play with. These commands are scr2txt (/usr/ports/textproc/scr2txt) and scr2png (/usr/ports/graphics/scr2png).
They can then be combined using one single line:

$ vidcontrol -p < /dev/ttyv0 | scr2txt > /tmp/screenshot.txt

The -p flag instructs vidcontrol to get the current content of the corresponding video buffer. scr2txt reads a vidcontrol dump file from standard input and writes a txt equivalent file to standard output. scr2png works in a similar fashion for png files.

These are the contents of the screenshot.txt file:

$ cat /tmp/screenshot.txt 
[n0str0m0@beastie ~]$ who am i                                                  
n0str0m0         ttyv0    Apr  5 18:59                                          
[n0str0m0@beastie ~]$                                                           
<some blank lines here>                                                                                


speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*Required Fields