Putty to Windows shell: Is there any command to copy text/output to clipboard?

2

3

If I do in Windows shell:

C:\Users\Luis>echo hello
hello

... the output goes to screen/terminal (stdout, we could say). But if I do:

C:\Users\Luis>echo hello | clip

... the output goes to clipboard, so I can paste it in any other program.

If I log to any Windows remote shell by using Putty it would be fine to have some equivalent tool, but just trying to use "clip" gives no results at all, and the Copy All To Clipboard option of Putty client is not exactly the same (it copies the whole screen).

I don't know if this is server-dependant: my server at the Windows side is Bitvise SSH Server.

Thanks you.

Sopalajo de Arrierez

Posted 2015-01-06T22:22:26.723

Reputation: 5 328

2clip is being executed server side, and has no knowledge of your SSH session, so there's no way your client is going to see the effects of that command. Unless the Bitvise Server has something included, I don't think what you want to do is possible. – heavyd – 2015-01-06T23:34:06.283

This does not answer your question directly but Windows Remote Desktop has clipboard integration along with other resource sharing. – Pawel Debski – 2019-10-09T18:15:45.090

Answers

1

There's no mechanism in SSH protocol (or Terminal emulation) to store any data to client-side clipboard. No matter what your SSH/terminal client or server is.

Though, in PuTTY, if you select a part of an output on the terminal screen (using mouse), it gets copied to clipboard.

See PuTTY FAQ How do I copy and paste between PuTTY and other Windows applications?

Copy and paste works similarly to the X Window System. You use the left mouse button to select text in the PuTTY window. The act of selection automatically copies the text to the clipboard: there is no need to press Ctrl-Ins or Ctrl-C or anything else. In fact, pressing Ctrl-C will send a Ctrl-C character to the other end of your connection (just like it does the rest of the time), which may have unpleasant effects. The only thing you need to do, to copy text to the clipboard, is to select it.

Martin Prikryl

Posted 2015-01-06T22:22:26.723

Reputation: 13 764