# replacement for VNCsnapshot



## sajansen (Sep 10, 2020)

Hey,

Its my first post here and i hope its in the right place.
I came from debian and windows so FreeBSD is a bit of a puzzle on some parts.

I am looking for a way to take screenshots of my VNC hosts from a script.
Previously i used VNCsnapshot for this, yes i know that pice of software is from 2004... but still it did what i needed it to do.
I was wondering if there is another tool that can do the same.

What i need it to do is as follows: i have a script (posted below) and it should take screenshots and move on to the next client. One thing is, this box is headless so everything needs to be done from the cli.


```
#!/bin/sh
awk '{print $1}' < ../Lists/vnc-ip.txt | while read ip; do
    echo "Running: $ip"
    timeout 5s vncsnapshot "$ip" "../VNC/$ip.jpg"
done
```

Can anyone help me with this?

My OS is Freenas 11.3U4.1 - FreeBSD 11.4-RELEASE-p3 Jail


----------



## olli@ (Sep 10, 2020)

I’m afraid I don’t know an existing tool that does what you want.

However, it might be possible to construct something yourself. Basically, you could start a virtual X server (x11-servers/xorg-vfbserver). It does not use a physical display, so it can run on a headless machine. See the Xvfb(1) manual page. Then your script can start a vncviewer(1) (net/tightvnc) in the background, sleep for a few seconds, then use another tool to take a screenshot of the vncviewer (for example, using the import(1) utility of the graphics/ImageMagick7 package). Then you can kill the vncviewer and continue with the next machine.

Admittedly it’s kind of a “hack” and requires some work, but I think it should work.


----------



## kpedersen (Sep 10, 2020)

There is a vnc2mpg sample here: https://github.com/LibVNC/libvncserver/tree/master/client_examples
You will need to compile it yourself. libvncserver is a pain to compile (use the package) but then this single c file isn't so bad.

You could perhaps hack at this fairly easily to integrate lodepng or std_image_write to save the screen buffer as an image rather than mpg file.
https://lodev.org/lodepng/
https://github.com/nothings/stb

Also, I could have sworn OpenCV had the functionality to stream from a VNC input but I must have been dreaming. Shame because there are loads of tools to export the pixel buffers. If you don't mind Python that would have been like 5 lines (if it existed...).


----------



## GogoFC (Mar 4, 2022)

olli@ said:


> Admittedly it’s kind of a “hack” and requires some work, but I think it should work.


Do you know how to start xvfb , I tried running the command, also find didn't find it at all, how would I start it at all. Linux people say xvfb-run app


----------



## grahamperrin@ (Mar 4, 2022)

sajansen welcome to FreeBSD Forums.



sajansen said:


> … FreeBSD 11.4-RELEASE-p3 Jail



If you're not already aware, it reached end of life around five months ago, so please be prepared for the possibility of something not working as expected. 

More formally: 









						Topics about unsupported FreeBSD versions
					

The FreeBSD Forums cater primarily to end-users and systems administrators. As such, the Forums focus almost exclusively on FreeBSD versions that are officially supported according to the official FreeBSD website. Since resources are scarce, the FreeBSD Forums strongly suggest that anyone asking...




					forums.freebsd.org
				




Security context: Unsupported FreeBSD Releases | The FreeBSD Project

Ports and Packages for Supported Releases | The FreeBSD Project (ignore the lines for stable/11 and releng/11.4; a fix for the page is in the pipeline).


----------

