How to take a screenshot of linux console without x windows through SSH or capture command output to image or HTML file?

keith_opswat used Ask the Experts™
Hello all!! I was hoping that someone here could help teach me how to take a screenshot of my linux console if I don't have an X-Windows installed. I just have a few commands I want it to capture the output either in an image file or input it to an html file. It would be best if I could run this in a cron job but I'm just not sure how. I tried to use import through ImageMagick but it gives me an x11 error which I'm quite sure is related to that I don't have  a GUI installed.

Any help would be appreciated.I installed scrot but not sure how ot use it or if I installed it right.

Thanks a lot in advance!!!

Also, just an FYI I'm running Centos 5.5 x86_64
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Let's see if this helps:

Try pressing the 'Prt Scr' key (print screen) on the keyboard.... or if that fails then try this.

Open a console and type the following:-
import -window root filename.ext

Where filename.ext is the filename you want to give to your screenshot. You can then check the directory you are in, and there will be the screenshot waiting for you.

If you want to add a delay BEFORE the shot is taken (so you can move stuff out of the way and it sounds like this would help you) then add a sleep command as follows:-
sleep 3s; import -window root screenshot.png

The above waits 3 seconds before taking the screenshot and saves it in PNG format.  Obviously, you can adjust that time delay.


I'm trying to automate it so prnt screen won't work. I don't want to have to SSH into the server everytime. I'm trying to setup for the server to send me the output of a couple commands and save the files somewhere so another script I have will display this information on a huge screen at work.

I've tried the import command before (Like I said I already have image magick installed) but I get the following error.

By default, 'file' is written in the MIFF image format.  To
specify a particular image format, precede the filename with an image
format name and a colon (i.e. ps:image) or specify the image type as
the filename suffix (i.e.  Specify 'file' as '-' for
standard input or output.
import: delegate library support not built-in `' (X11) @ error/import.c/ImportImageCommand/1297.

I'm quite sure it's because I don't have any X windows GUI installed.

I can make it put the output of a command into a text file by doing free > /tmp/free.txt. But I was just hoping to do this in an image somehow.

I read that scrot can capture the console into an image without X installed but when I try to run scrot I get the following

scrot: error while loading shared libraries: cannot open shared object file: No such file or directory

And I'm not sure how to fix this. So any other ideas? If there was a way to convert the text output above into an image or have it automatically format as a basic html page then I could have my script on another machine capture the screenshot of it. Is there a way to convert txt to an image or have the output go into an html file? Here's a very rudimentary idea of what I'm thinking...

<body bgcolor="black"><font color="white">
<p> Ouput of free command goes here</p></body>

I realize that's a horrible web page just trying to get a point across... iS there a way to have it dump the output of a command to a certain place in a file instead of having it replace everything in the file?

Thanks for your help.
Distinguished Expert 2017
I understand what you want to achieve, i.e. the ability to view output of some commands on a centralized server.

What are the commands that you want to execute?

Would a tool that would poll and provide you with the option of graphical representation of various datapoints would be something of interest?

You can setup an agent on each system.
You can have a PHP/SHTML/CGI page that would connect to each agent and make the request for the specific command and then provide the output in the page.

I think your concentration of snapshot/graphical diverted you from the easy solution.
i.e. get the data as it is provided by the execution of the command and then mold the data to appear as you see fit.
HTML, if you want it to appear as an image, not sure why you would need to make sure that all the necessary components that are needed to generate an image from text based input is installed on the system where this process will be run.


Thank you... I get so caught up in trying to come up with a solution myself because I'm trying to get better at linux and I find the challenge fun that I over look a better alternative that saves time. Thanks :) I've actually used RRDTool befoer in the past and am in the process of configuring Groundworks Open Source which includes Nagios, RRD Tool etc... I've never setup and configured cacti before so good practice for me.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial