1

I'm trying to take a screenshot of a remote host (using xwd) and convert it to png (using convert). I need it to be an unattended oneliner, so this is what I'm doing:

sshpass -p THE_PASSWORD ssh user@192.168.1.1 xwd -display :0 -root | convert xwd:- output.png

The problem is that the generated PNG file is cropped, only the top part of the screen is shown. If I do the process in two steps, it works:

sshpass -p THE_PASSWORD ssh user@192.168.1.1 xwd -display :0 -root > output.xwd
convert output.xwd output.png

But I need it to be done in just one command.

I'm guessing it has something to do with the rate at which convert is receiving the data from the remote xwd command. I've tried using stdbuf as mentioned here to increase the buffer size, but does not seem to have any effect.

I'm using ImageMagick 6.7.8.9-15.

1 Answers1

1

I need it to be done in just one command

If "one command" means a single shell expression, you could chain them with &&:

sshpass -p THE_PASSWORD ssh user@192.168.1.1 xwd -display :0 -root > output.xwd && convert output.xwd output.png

Or if that doesn't work, you could use process substitution:

sshpass -p THE_PASSWORD ssh user@192.168.1.1 convert <(xwd -display :0 -root) output.png
bagrounds
  • 11
  • 1