I have a text file on a virtual machine (without a GUI) to which I am connected through ssh in VSCode. I want to write python code that reads some text from this file and copies this to the clipboard so that I can paste this text into the browser which I have open on my local machine.
I tried using pyperclip
. Specifically, the code looks something like:
import pyperclip
...
pyperclip.copy(string)
...
I get the following error:
Pyperclip could not find a copy/paste mechanism for your system.
I have xclip
and xsel
installed on the virtual machine. I read answers where it states that pyperclip
does not work because it copies to the clipboard and clipboard is part of the GUI which a VM does not have. My final aim is to have it copied so that I can just paste it into the browser by using Ctrl+V
. Basically, I want an automatic python code that does the equivalent of using Ctrl+C
in a remote file open in a VSCode window.