Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I wrote a bash script as below:

#!/bin/bash
echo "Enter a file name"
read filename
import -window root $HOME/Desktop/$filename.png

I expected this script to take a screen shot and save the image with the given filename on my desktop.

Problem: My Ubuntu terminal is giving error:

import: Command Not Found

share|improve this question

3 Answers 3

You need to install the package imagemagic to use import command.

sudo apt-get install imagemagick

Install via the software center imagemagick Install imagemagick

This will allow you to use import command. Also try out graphicsmagick-imagemagick-compat package.

other alternatives to import are

  • scrot

    To install scrot: sudo aptitude install scrot

Install via the software center scrot Install scrot

usage: `scrot screen.png`
  • gnome-screenshot

sudo aptitude install gnome-screenshot

Install via the software center gnome-screenshot Install gnome-screenshot

share|improve this answer
    
hi devav2...I am getting a message that says -- unable to locate package scrot.. any suggestions –  Prabhu Kl Oct 18 '12 at 9:22
    
Prabhu, Try to find the package in Ubuntu Software Center or try changing your software source server to a different one. –  devav2 Oct 18 '12 at 9:28

You can use the best screenshot tool shutter Install shutter for use in scripts too! And I believe, this is the most powerful tool and give you most advanced and fine-tuned options to use in scripts.

Install it with the command in a terminal

sudo apt-get install shutter

or using the software center (by clicking the big button below)

Install via the software center

And after installation, use this command to take a screenshot of the whole display and save the screenshot in a file named, myshot.png

shutter -f -o myshot.png -e
  • The -f tells shutter to take a screenshot of the whole display. You could also use -a to take a screenshot of the active window, or tell it to take a shot from any specific window.

  • The -o option is used for telling shutter the output file name. You could specify any file name

  • The e option causes shutter to exit after taking the screenshot.


The output of shutter --help is given below for reference.

Usage:
    shutter [options]

Options:
    Example 1
            shutter -a -p=myprofile --min_at_startup

    Example 2
            shutter -s=100,100,300,300 -e

    Example 3
            shutter --window=.*firefox.*

    Example 4
            shutter --web=http://shutter-project.org/ -e

  Capture Mode Options:
    -s, --select=[X,Y,WIDTH,HEIGHT]
            Capture an area of the screen. Providing X,Y,WIDTH,HEIGHT is
            optional.

    -f, --full
            Capture the entire screen.

    -w, --window=[NAME_PATTERN]
            Select a window to capture. Providing a NAME_PATTERN (Perl-style
            regex) ist optional.

    -a, --active
            Capture the current active window.

    --section
            Capture a section. You will be able to select any child window
            by moving the mouse over it.

    -m, --menu
            Capture a menu.

    -t, --tooltip
            Capture a tooltip.

    --web=[URL]
            Capture a webpage. Providing an URL ist optional.

    -r, --redo
            Redo last screenshot.

  Settings Options:
    -p, --profile=NAME
            Load a specific profile on startup.

    -o, --output=FILENAME
            Specify a filename to save the screenshot to (overwrites any
            profile-related setting).

            Supported image formats: You can save to any popular image
            format (e.g. jpeg, png, gif, bmp). Additionally it is possible
            to save to pdf, ps or svg.

            Please note: There are several wildcards available, like

             %Y = year
             %m = month
             %d = day
             %T = time
             $w = width
             $h = height
             $name = multi-purpose (e.g. window title)
             $nb_name = like $name but without blanks in resulting strings
             $profile = name of current profile
             $R = random char (e.g. $RRRR = ag4r)
             %NN = counter

            The string is interpretted by strftime. See "man strftime" for
            more examples.

            As an example: shutter -f -e -o './%y-%m-%d_$w_$h.png' would
            create a file named '11-10-28_1280_800.png' in the current
            directory.

  Application Options:
    -h, --help
            Prints a brief help message and exits.

    -v, --version
            Prints version information.

    -d, --debug
            Prints a lot of debugging information to STDOUT.

    --clear_cache
            Clears cache, e.g. installed plugins, at startup.

    --min_at_startup
            Starts Shutter minimized to tray.

    --disable_systray
            Disables systray icon.

    -e, --exit_after_capture
            Exit after the first capture has been made. This is useful when
            using Shutter in scripts.
share|improve this answer
    
I love shutter as a GUI app, this is a great detail of the CLI, thanks! –  TryTryAgain Mar 21 '13 at 22:06

To install imagemagick, containing the program import, see the other answer. However, you can also launch gnome-screenshot from command line by calling gnome-screenshot. The applet will take the screenshot without delay and show a dialog to enter a file name:

enter image description here

share|improve this answer
    
gnome-screenshot command is working good...Thank you...Is there a way to pass a string argument to this command so that the screenshot is saved with the given string name? –  Prabhu Kl Oct 18 '12 at 8:16
    
No, fully automatic screenshots are better done with import. –  January Oct 18 '12 at 8:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.