jump to navigation

Capture and Post Screenshots to a Website, Instantly December 10, 2005

Posted by Carthik in ubuntu.

The following script is from Linux Desktop hacks and allows you store screenshots locally as well as publish them to a web page. This is really useful to show people instantly what you see on your screen. It also automatically generates a thumbnail. You can change the delay
before the snap, the quality, the size of the thumbnail and, if you want, have it loop – that is, take a new screenshot every n seconds.

To use this script you need scrot (you can apt-get install scrot).
You also need perl (check if you have it by doing $perl -v) and you need the perl Net::Ftp extension.

Then you have to save the script (as, say scrpost.pl), and make it executable (chmod +x scrpost.pl)
You install scrot and then make a bash script like this, save it as a perl
script and execute it with, for example, ./screenshot.pl:

#!/usr/bin/perl -w
use Net::FTP; #start ftp

#This script puts screenshots directly on a website rather than saving them
#locally. It comes from Desktop Hacks, By Nicholas Petreley, Jono Bacon
#First Edition March 2005, ISBN: 0-596-00911-9 Copyright (c) 2005
# O'Reilly Media, Inc.

#$delay = "5"; #program loop delay in seconds
$delay_snap = "3"; #screen capture delay in seconds
$quality = "75"; #scale of 1-100
$thumb = "25"; #thumbnail size as percentage
$server = "user.com";
$username = "user";
$password = "password";
$serverfolder = "/usr/www/users/yourdir/screenies";
$localfolder = "/home/user/Desktop/screenies";

 system("scrot $localfolder/currentscreen.jpg -d $delay_snap --thumb
$thumb --quality $quality"); #takes the screenshot
 $ftp = Net::FTP->new($server, Debug => 0); #connect
 $ftp->login($username, $password); #log in
 $ftp->binary(); #change to binary transfer mode
 $ftp->cwd($serverfolder); #change to desired server directory
 $ftp->delete("$serverfolder/currentscreen.jpg"); #delete any old
 $ftp->delete("$serverfolder/currentscreen-thumb.jpg"); #delete any old
screenshot thumbnail
 print "Deleted old screenshot and thumbnail images\n";
 $ftp->put("$localfolder/currentscreen.jpg"); #uploading image
 $ftp->put("$localfolder/currentscreen-thumb.jpg"); #uploading thumbnail
 print "Completing upload\n";
 $ftp->quit; #close ftp session
 print "Done. Quitting. Later, dude.\n";


1. Kate . L .W - December 10, 2005

A very nice site you have here dedicated to Ubuntu. I enjoyed reading all your posts. I am a new Ubuntu user and equally new Linux user. Infact I started using Linux only two weeks back. And in this short while I have learned so much. It is really awesome.
btw, I came across your site at linuxhelp.blogspot.com where it is listed as one of the 10 most popular ubuntu sites on the net.

Thanks for maintianing such a good blog dedicated to Ubuntu.

2. ubuntonista - December 10, 2005

Thanks, Kate. I hope to be of some use to new users, being one myself.

3. Eugene - December 11, 2005

This solution is really awesome – thank you very much. I’ve heard about such a script but only today have found it

4. u - December 11, 2005

you can also enter a url like sftp://hostname/home/username/public_html if you
do System->Take Screenshot, select “Other…” in “Save in folder” and press ctrl-l.

If you used Places -> Connect to Server before taking a screenshot it will also
show up in the “Save in folder” list.

This is using gnome vfs and supports
ftp, sftp, http/https (only if server supports webdav), smb and possibly more.

5. eldee - December 13, 2005

this is a nie site u’ve got here keep it up man..

6. louis - January 17, 2006

Looks great, but I get the following. I’m using, mepis, (debian based) with KDE. Would that be an issue?

louis@5[~]$ ./scrpost.pl
scrot: option `–thumb’ requires an argument
sh: line 1: 25: command not found
Can’t locate object method “screenshot” via package “Net::FTP” at ./scrpost.pl line 28.

7. Yannick - January 19, 2006

There is another script on the french Ubuntu forums
(comments/text are in french but…)

8. Cereal - March 20, 2006

For the Net::FTP problem just install libnet-perl package from synaptic (or apt-get).

For the -thumb problem is simple, adjust the second line of the code.. in this blog the command got broken in two lines and gives you the problem

@all (if interested)
I used xbindkeys (and xbindkeys-config) to create a keyboard shorcut.. so now I’ve only to press F2 to upload my latest screenshot..

@ubuntonista, really great blog ^_^ bye

9. F - May 28, 2006

So excited to come across this site! looks great!

However, for some reasons I cann’t see the complete code on my screen. It sounds that the end of the lines are cut. May I ask you please to instruct me to get the complete code.


10. junaid - August 1, 2007

hey bud,…………

very appreciated effort………but i wonder if this will be able to take screenshoots of multi urls at a time………

pls reply,……..its urgent

11. porno sikiş - September 27, 2010

Thanks, Kate. I hope to be of some use to new users, being one myself.

12. sex sikiş - September 28, 2010

This is using gnome vfs and supports
ftp, sftp, http/https (only if server supports webdav), smb and possibly more.

13. Nichole - July 29, 2013

I’m extremely impressed with your writing talents and also with the layout for your blog. Is this a paid subject matter or did you customize it your self? Either way stay up the excellent high quality writing, it’s uncommon to see a nice weblog like this one nowadays.


14. WebDoctorAdvice.com - April 4, 2014

Thanks for finally talking about >Capture and Post Screenshots to a
Website, Instantly | Ubuntu Blog <Liked it!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: