Screenshot via command-line in Linux

Have you ever wondered how to take a screenshot remotely, via the command line in a Linux system? Here is a way to do it. At the bottom you can also find a script to move it to the root of your personal page (if you have) to open the screenshot in your browser.

I have a Lisp program running inside Slime (The Superior Lisp Interaction Mode for Emacs) in an emacs instance running in my office computer. It has been running for quite a few hours (days), and top still marks it as 100%... The problem: if emacs/Slime cuts the Lisp connection with the Lisp client, it goes runaway. And I needed a way to "see" if emacs was still connected. Without going there, obviously.

Remote screen-shooting via the command line is the solution. The trick: use xwd:
xwd -root -display :0.0 -out Screenshot.xwd
Then ImageMagick's mogrify to turn it into something easier to open:
mogrify -format jpg Screenshot.xwd
Caveats: In my case, the first two times I got a black screen. Why?
killall gnome-screensaver (or your particular instance of screen-saver)
And voilĂ :

emacs still connected

The script to move it to your public_html folder:
Written by Ruben Berenguel