Link to home
Start Free TrialLog in
Avatar of keith_opswat
keith_opswatFlag for United States of America

asked on

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

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
Avatar of MBobrek
MBobrek
Flag of United States of America image

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.
Avatar of keith_opswat

ASKER

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. image.ps).  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: libgiblib.so.1: 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...

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

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.
ASKER CERTIFIED SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.

Thanks!!