
Put Screenshots Automatically on the Web #65
Chapter 8, Desktop Programs
|
203
HACK
The script this hack uses to upload the screenshot is written in Perl and
requires
Net::FTP, a web server, and a simple program called scrot; all of
these are freely available online.
Installing scrot
You can find scrot, a command-line screen-capture tool (similar to import,
which is included with ImageMagick), at http://linuxbrit.co.uk/scrot/.
Extract, compile, and install the software with these few commands:
foo@bar:~$ wget http://linuxbrit.co.uk/downloads/scrot-0.8.tar.gz
foo@bar:~$ tar -zxvf scrot-0.8.tar.gz
foo@bar:~$ cd scrot-0.8
foo@bar:~$ ./configure
foo@bar:~$ make
foo@bar:~$ su -c "make install"
With scrot installed, you can use it to take screenshots anytime you want;
just find the nearest terminal and type
scrot. For more information on scrot,
see the manpage.
Perl is likely to be installed already on your Linux system, but if it isn’t, you
should use your distribution’s installation tool to install it. In addition to the
stock Perl installation, you also need the
Net::FTP module that you can
install by using CPAN, Perl’s module repository:
foo@bar:~# perl -e shell -MCPAN
foo@bar:~# install Net::FTP
The Code
This is where all the magic is. Just write each line into your favorite text edi-
tor, whether it is emacs or vim or something else, and save it as
autoscreenshot.pl in $localfolder:
#!/usr/bin/perl -w
use Net::FTP; ...