Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Set up a write-only networked clipboard Network
Tiger only hintEver wanted to send text snippets from one machine to another via the Terminal? Save this XML code to a file named pbcopy.plist in your user's Library -> LaunchAgents folder (note that you'll probably have to create the LaunchAgents folder).

Next, execute this command in Terminal (or just logout and login):
$ launchctl load ~/Library/LaunchAgents/pbcopy.plist
Now you'll be able send any text over the network right to the clipboard on this machine via nc (netcat) or bash, like this:
$ echo test | nc -w1 1.2.3.4 2224    [or]
$ echo test >/dev/tcp/1.2.3.4/2224
Note that the second example is a bash feature and may be disabled on some systems. In both examples, replace 1.2.3.4 with the IP address of the receiving Mac (the one running the XML code), and make sure your firewall allows access to port 2224.

This is very convenient, but also very insecure. However, if you add the following lines to the pbcopy.plist file, between the dict tags in the Listeners section, then it will listen on only the loopback interface:
<key>SockNodeName</key>
<string>127.0.0.1</string>
Once that's done, you may access the service from a remote machine on 127.0.0.1:2224 if you ssh there with this option in the .ssh/config file:
RemoteForward 2224 127.0.0.1:2224
This one is a default for all my ssh connections, because very often I need to transfer a lot of text output to my local machine from many kinds of unixes. Unfortunately, Terminal's cut-n-paste can't handle this without breaking lines or truncating the text to the size of the scroll buffer.

Another trick -- if you installed SubEthaEdit and its command line tool called see (/usr/bin/see), you may put that program in the .plist (instead of /usr/bin/pbcopy), and then the editor's window will pop-up with the text content that was sent.

[robg adds: I tested this, and it worked quite well ... very well. I was able to accept text from anywhere on the net, as tested by friends in The Netherlands and Montreal. I suggest that if you implement this, you use the ssh restriction, as it does seem somewhat insecure. To remove the agent, use launchctl unload ~/Library..., then delete the file.]
    •    
  • Currently 2.60 / 5
  You rated: 1 / 5 (5 votes cast)
 
[11,570 views]  

10.4: Set up a write-only networked clipboard | 11 comments | Create New Account
Click here to return to the '10.4: Set up a write-only networked clipboard' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Setup a write-only networked clipboard
Authored by: adrianm on Sep 16, '05 10:51:39AM
If you are going to use ssh anyway, why not just type something lilke:

echo test | ssh remotehost /usr/bin/pbcopy
?

You'd need to turn on sshd (remote terminal access, or whatever it's called) in Sharing prefs, but then you'd have to do that anyway.

[ Reply to This | # ]

10.4: Setup a write-only networked clipboard
Authored by: xSmurf on Sep 16, '05 03:20:18PM
This did not work for me (sending for a 10.3 to 10.4 machine).
I have used the launchd method and >/dev/tcp/... (the other one didn't work)
As for security, I have set the port to be blocked by the router.
I have also added three aliases to my bash_profile.

alias echo2remote='echo "$1" > /dev/tcp/REMOTEHOST/2224'
alias cat2remote='cat $1 > /dev/tcp/REMOTEHOST/2224'
alias paste2remote='/usr/bin/pbpaste > /dev/tcp/REMOTEHOST/2224'

Works like a charm, very useful...

---
Free iPods, now in Canada to! Get yours : http://tinyurl.com/75yta

PM G4 DP 800 / 1.25gb / 120Gb+80Gb / CD/DVD±RW/RAM/DL
- The only APP Smurf

[ Reply to This | # ]

10.4: Setup a write-only networked clipboard
Authored by: fabrizio on Sep 16, '05 01:07:12PM
Why don't use DropCopy, that does this and more?

[ Reply to This | # ]
10.4: Setup a write-only networked clipboard
Authored by: Mikey-San on Sep 16, '05 06:11:16PM

Because this isn't really complicated, and some of us like rolling our own solutions. Perhaps for some, this is more flexible than someone else's program (which is apparently in "unrestricted beta", which implies to me that the final release isn't freeware).



[ Reply to This | # ]
clipboardsharing does the same via rendevous/bonjour
Authored by: nick on Sep 16, '05 06:29:19PM

http://www.versiontracker.com/dyn/moreinfo/macosx/18901



[ Reply to This | # ]
clipboardsharing does the same via rendevous/bonjour
Authored by: atverd on Sep 16, '05 06:39:53PM

Guys, all those tools are fine, but they are not command line based and they are mac-only. This hint doesn't require any special software on a remote side and will work for any unix or windows like system.



[ Reply to This | # ]
clipboardsharing does the same via rendevous/bonjour
Authored by: jiclark on Sep 17, '05 04:22:39PM

Yes, but for the many here that are not at all command-line-savvy, knowing about the apps that might be available to do some of the same things are just as helpful...

Please don't start telling us that command-line oriented hints can't have someone chiming in with a GUI alternative, okay?

Thanks,
John



[ Reply to This | # ]
clipboardsharing does the same via rendevous/bonjour
Authored by: david-bo on Sep 20, '05 02:13:15PM

How does this hint work with Windows and other Unixes? pbcopy is very Mac-/Nextish, isn't it?

---
http://www.google.com/search?as_q=%22Authored+by%3A+david-bo%22&num=10&hl=en&ie=ISO-8859-1&btnG=



[ Reply to This | # ]
10.4: Setup a write-only networked clipboard
Authored by: Arakageeta on Sep 17, '05 05:45:02PM

What's wrong with email?



[ Reply to This | # ]
10.4: Setup a write-only networked clipboard
Authored by: sjk on Sep 17, '05 07:38:19PM

Mail has less immediacy and more "overhead" than the other methods suggested for doing this sort of thing.



[ Reply to This | # ]
10.4: Setup a write-only networked clipboard
Authored by: kenahoo on Sep 19, '05 11:39:23AM

This is a nice hint. I do think it's a different category than the quick-file-copying apps suggested here, because you often want to share just a hunk of text without having to wrap it all up in a file.

If the computers you're sharing between are both sitting on the same desk, I enthusiastically recommend Synergy. I use it to share between my WinXP machine and my Panther laptop.

-Ken



[ Reply to This | # ]