# Clipboard write

**URL:** <https://discourse.nodered.org/t/clipboard-write/7975>\
**Category:** General\
**Created:** [14 February 2019 21:59 UTC](https://discourse.nodered.org/t/clipboard-write/7975 "2019-02-14T21:59:27Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabnavigator](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fabnavigator/32/5403_2.png) [@fabnavigator](https://discourse.nodered.org/u/fabnavigator)\
**Post date:** [14 February 2019 21:59 UTC](https://discourse.nodered.org/t/clipboard-write/7975/1 "2019-02-14T21:59:27Z")

</div>

Anyone ever use the clipboard-write node? I've got a debug node hooked up in parallel that says msg.payload = "x", but when I paste from the clipboard it just gives me "payload".

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 February 2019 22:13 UTC](https://discourse.nodered.org/t/clipboard-write/7975/2 "2019-02-14T22:13:09Z")

</div>

a simple inject seems to work for me... can you share just that part of your flow that fails ?

---

<div class="post-metadata">

**Author:** ![fabnavigator](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fabnavigator/32/5403_2.png) [@fabnavigator](https://discourse.nodered.org/u/fabnavigator)\
**Post date:** [14 February 2019 23:14 UTC](https://discourse.nodered.org/t/clipboard-write/7975/3 "2019-02-14T23:14:58Z")

</div>

Hmm. I think I might be off track here. How did you access the clipboard? I realize that this probably isn't going to put anything on the clipboard of the device running the UI. Which is what silly me was hoping for.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 February 2019 23:28 UTC](https://discourse.nodered.org/t/clipboard-write/7975/4 "2019-02-14T23:28:51Z")

</div>

good point - i was just trying it all on the one machine so of course it works 🙂

It is based on this library - [https://www.npmjs.com/package/copy-paste](https://www.npmjs.com/package/copy-paste) so I think you are correct - will be the server side clipboard it goes into.

---

<div class="post-metadata">

**Author:** ![fabnavigator](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fabnavigator/32/5403_2.png) [@fabnavigator](https://discourse.nodered.org/u/fabnavigator)\
**Post date:** [15 February 2019 01:15 UTC](https://discourse.nodered.org/t/clipboard-write/7975/5 "2019-02-15T01:15:13Z")

</div>

I just wanted to be able to copy the notification text, and it looks like it lets me do that, so I'm good. Thanks. Are you the main nr guy?

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [17 February 2019 00:55 UTC](https://discourse.nodered.org/t/clipboard-write/7975/6 "2019-02-17T00:55:14Z")

</div>

Are you folks discussing [node-red-contrib-clipboard](https://github.com/zuhito/node-red-contrib-clipboard)? I haven't tried it before, and I can't make it work. I'm running NR v0.20.0-beta.5 and Node.js v8.15.0, and the browser is Safari on macOS 10.11.6. My flow is

```auto
[{"id":"f23d38c3.ea5b","type":"inject","z":"d1d36546.c9449","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":90,"wires":[["f9d764ea.2db1b8"]]},{"id":"f9d764ea.2db1b8","type":"clipboard-read","z":"d1d36546.c9449","name":"","x":390,"y":90,"wires":[["681321c1.855588"]]},{"id":"681321c1.855588","type":"debug","z":"d1d36546.c9449","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":90,"wires":[]},{"id":"f1bda44b.21bff8","type":"inject","z":"d1d36546.c9449","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":170,"wires":[["656efb0d.f04504","bacd0528.d8cfc"]]},{"id":"656efb0d.f04504","type":"clipboard-write","z":"d1d36546.c9449","name":"","x":420,"y":170,"wires":[]},{"id":"bacd0528.d8cfc","type":"debug","z":"d1d36546.c9449","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":410,"y":220,"wires":[]}]

```

The `clipboard-read` node reports an error

> Error: Command failed: xclip -selection clipboard -o  
> Error: Can't open display: (null)

and the `clipboard-write` node fails silently. Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![fabnavigator](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fabnavigator/32/5403_2.png) [@fabnavigator](https://discourse.nodered.org/u/fabnavigator)\
**Post date:** [17 February 2019 01:38 UTC](https://discourse.nodered.org/t/clipboard-write/7975/7 "2019-02-17T01:38:29Z")

</div>

Yes we are. I was running NR in chrome on windows, and was thinking that content would go between NR and my windows clipboard. Of course, that isnt the case, so I lost interest. What are you hoping to do?

---

<div class="post-metadata">

**Author:** ![scubachristopher](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scubachristopher/32/19898_2.png) [@scubachristopher](https://discourse.nodered.org/u/scubachristopher)\
**Post date:** [3 May 2020 18:14 UTC](https://discourse.nodered.org/t/clipboard-write/7975/8 "2020-05-03T18:14:11Z")

</div>

I have a dashboard that surfaces a button to copy some of the dashboard content to the clipboard. I store content in a global variable referenced by many nodes. All is well.

I also use clipboard-write to copy some of that content to the clipboard. msg.payload is set to that content in a function node before the clipboard-write. clipboard-write seems not to work.

```auto
[{"id":"a2bd589d.078638","type":"clipboard-write","z":"dashboard_id","name":"","x":560,"y":1160,"wires":[]},{"id":"ea301efb.3b4c4","type":"ui_button","z":"dashboard_id","name":"Copy to Clipboard","group":"ui_group_id","order":10,"width":"3","height":"1","passthru":false,"label":"Copy to clipboard","tooltip":"","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":110,"y":1120,"wires":[["7802e1ad.82c36"]]},{"id":"7f3b7207.6806dc","type":"debug","z":"dashboard_id","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":530,"y":1120,"wires":[]},{"id":"7802e1ad.82c36","type":"function","z":"dashboard_id","name":"payload to copy","func":"var lines=\"this is a test\"\nmsg.payload=lines\nreturn msg\n","outputs":1,"noerr":0,"x":320,"y":1120,"wires":[["7f3b7207.6806dc","a2bd589d.078638"]]},{"id":"ui_group_id","type":"ui_group","z":0,"name":"Control panel","tab":"cd39e1f4.b9df3","order":1,"disp":true,"width":"40","collapse":false},{"id":"cd39e1f4.b9df3","type":"ui_tab","z":0,"name":"Laguna Research Instrument Dashboard","icon":"dashboard","disabled":false,"hidden":false}]

```

Any insights would be appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [3 May 2020 20:08 UTC](https://discourse.nodered.org/t/clipboard-write/7975/9 "2020-05-03T20:08:16Z")

</div>

Have you tried a simple case? Try this

```auto
[{"id":"2b78b1c6.a96486","type":"inject","z":"646a34cd.8135ac","name":"","topic":"","payload":"Hello World","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":60,"wires":[["612c7ffd.e6311"]]},{"id":"69a1604e.addfe","type":"clipboard-read","z":"646a34cd.8135ac","name":"","x":320,"y":120,"wires":[["f767a1a8.31317"]]},{"id":"612c7ffd.e6311","type":"clipboard-write","z":"646a34cd.8135ac","name":"","x":320,"y":60,"wires":[]},{"id":"f767a1a8.31317","type":"debug","z":"646a34cd.8135ac","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":530,"y":120,"wires":[]},{"id":"a720c660.2beb08","type":"inject","z":"646a34cd.8135ac","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":120,"wires":[["69a1604e.addfe"]]}]

```

If it doesn't work then  
1 - what platform are you using (OS and release)  
2 - what version of Node-RED, node.js and dashboard? (you can get this from the startup log)

Your flow works for me.

---

<div class="post-metadata">

**Author:** ![scubachristopher](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scubachristopher/32/19898_2.png) [@scubachristopher](https://discourse.nodered.org/u/scubachristopher)\
**Post date:** [3 May 2020 21:25 UTC](https://discourse.nodered.org/t/clipboard-write/7975/10 "2020-05-03T21:25:30Z")

</div>

Wow -- thank you so much for responding so quickly. No joy:

```auto
Error: Command failed: xclip -selection clipboard -o
/bin/sh: 1: xclip: not found

Node-red: 1.0.5
[info] Node-RED version: v1.0.5
[info] Node.js version: v10.20.1
[info] Linux 4.15.0-1065-aws x64 LE

Host OS:
Linux ip-172-30-2-214 4.15.0-1065-aws #69-Ubuntu SMP Thu Mar 26 02:17:29 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
18.04.2 LTS (Bionic Beaver)
```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 May 2020 21:37 UTC](https://discourse.nodered.org/t/clipboard-write/7975/11 "2020-05-03T21:37:10Z")

</div>

That would seem to be a native OP application... so may need to be pre-installed... outside of Node-RED.

```auto
sudo apt-get install xclip

```

---

<div class="post-metadata">

**Author:** ![scubachristopher](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scubachristopher/32/19898_2.png) [@scubachristopher](https://discourse.nodered.org/u/scubachristopher)\
**Post date:** [3 May 2020 21:50 UTC](https://discourse.nodered.org/t/clipboard-write/7975/12 "2020-05-03T21:50:11Z")

</div>

Hmm -- installed xclip:

```auto
Error: Command failed: xclip -selection clipboard -o
Error: Can't open display: (null)

```

The github for node-red-contrib-clipboard shows the write js as:

```auto
var clipboard = require("copy-paste").global();

module.exports = function(RED) {
    function ClipboardWriteNode(config) {
        RED.nodes.createNode(this,config);
        var node = this;
        this.on('input', function(msg) {
            try {
                clipboard.copy(msg.payload);
            } catch (e) {
                node.error(e);
            }
            node.send(msg);
        });
    }
    RED.nodes.registerType("clipboard-write", ClipboardWriteNode);

```

If this is a js module, I don't get why it's calling xclip.

I was under the impression this module had been used. If not, I'll just write a bash script to call xclip with the content. Prefer to use nodes if possible -- cleaner.

What version are you on? Should I try to downgrade?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [3 May 2020 23:05 UTC](https://discourse.nodered.org/t/clipboard-write/7975/13 "2020-05-03T23:05:12Z")

</div>

I did it in MacOS and it worked fine
