On a Mac you might use python to "shell out" to pbcopy.
Can python send text to the Mac clipboard
Alternatively on a windows machine you might try the win32clipboard module.
How do I read text from the Windows clipboard in Python?
I suspect the linux solution is a google away, as these were.