我需要抓取在Ubuntu服务器12.04上运行的命令的截图,如
~$ id
uid=0000(local) gid=0000(localo) groups=1000(local)
~$ uname -a
Linux local 3.2.0-54-generic #82-Ubuntu SMP Tue Sep 10 20:08:42 UTC 2013 x86_64 GNU/Linux
和其他一些命令。
我找不到任何能完成这项工作的工具。我尝试了不同的工具,发现在 ArchWiki 但所有的人都给出了黑色的截图作为输出。像。
我试着用Xvfb ~$ Xvfb :1 -screen 0 1360x960x24 -extension RANDR &
从 imagick 创建显示和导入工具 ~$ DISPLAY=:1 import -window root -quality 100 /var/www/html/output/screenshot.png
捕捉屏幕截图,但它没有工作。
过了一段时间我才明白,原来显示屏是空的,黑色的图像才是正确的输出。
后来我发现 GraphTerm 一个在无头浏览器中访问终端并捕获屏幕截图的方法,但它不允许从终端向浏览器发送命令,但它确实说它在终端和浏览器实例之间建立了websocket连接。这些是我用来做这个的命令。
~$ sudo Xvfb :1 -screen 0 1360x960x24 -extension RANDR &
~$ gtermserver --terminal --auth_type=none & // Starts the graphical server in new browser
~$ DISPLAY=:1 chromium-browser http://localhost:8900/local/new/?cauth=1753c05fd738 &
~$ DISPLAY=:1 import -window root -quality 100 /var/www/html/output/screenshot.png
有没有其他方法可以做到这一点?或者我在这些步骤中做错了什么。
有一个非常简单的快捷键可以做到这一点。
Alt + PrtScrn -> to take the screenshot of a window(terminal window for you)
在ubuntu中,还有更多的快捷键可以进行截屏。
1.PrtScrn -> to take a screenshot of the desktop
2.shift + PrtScrn -> to take screenshot of area you selected.
希望能帮到你