Hey everyone, just wanted to share a quick project I built a bit ago and finally cleaned up enough to post.<p>The premise is simple, you have a file on one computer that you want on a different computer on the same network and don't want a lot of fuss.<p>For the file you want to copy, on the machine where the file is located, run:<p>./bcp filename<p>Now go to the computer (on the same network) where you want the file to be at, and run:<p>./bcp<p>The file will be copied over the network and you're done.<p>I created it as a nice way of not having to worry about ssh or anything else really. In fact, it is so simple, I use it on my local machine a lot when hopping around between terminals instead of remembering paths.<p>I have tested it on OSX and Linux.<p>Suggestions and comments welcomed.
$ nc -l 8888 > file<p>$ cat file | nc host.example.com 8888<p>I don't think a dedicated utility is required.<p>Edit: Sorry about my comment coming off as a bit hostile, I did not intend it to be.
It's neat. I noticed a couple of subtle bugs.<p>1) The code assumes both the client and the server have the same endian. This can be issue since a uint32 is used for both the synchronization code (BCP_CODE) and the port. This can easily fixed with htonl/ntohl conversions.<p>2) it assumes both the client and the server define int to be the same size (may or may not be true based on compiler/processor/OS combinations). If you use stdint definitions, this typically won't be an issue.
Udpcast:<p><a href="http://www.udpcast.linux.lu/" rel="nofollow">http://www.udpcast.linux.lu/</a><p>Can do this and other related useful things, including multicast of a file to N machines in parallel. Don't let the UDP bother you: it implements retry/checksum/etc on top of datagrams.<p>It's been around a few years, and is probably already in your distro.<p>It can pipe, as well as copy files, I wrote about it some time ago:<p><a href="http://kylecordes.com/2008/multicast-your-db-backups-with-udpcast" rel="nofollow">http://kylecordes.com/2008/multicast-your-db-backups-with-ud...</a>
Nice. Very Unix-ish in its spirit.<p>The client-server arrangement is backwards though :) Typical arrangement is for the clients to do the "anyone there?" broadcast, for the servers to reply and then the client would select the server, connect to it and they would go about their business. In your case, the server connects to the client. If you re-arrange this to natural client-server order, you should be able to get rid of the fork() call and this will help with portability (not that you probably care at this point).<p>Also,<p><pre><code> size = fread(&buf, 1, 100, ft)
</code></pre>
No harm in using chunks larger than 100, especially when dispensing larger files.<p>Also, consider switching to multicast for discovery.
I like how clever this is, but is there an option to <i>name</i> a bcp (or a planned option), so that I can send files among a big network with lots of people using this command concurrently?
It reminds me of <a href="http://www.fefe.de/ncp/" rel="nofollow">http://www.fefe.de/ncp/</a> It's always interesting when people come up with the same thing independently.
Try and add support for detecting piped input on the server side:<p><pre><code> bcp < filename
</code></pre>
because this would allow for things like<p><pre><code> cat filename | gzip | bcp
</code></pre>
with the receiving end doing<p><pre><code> bcp | gunzip > filename
</code></pre>
Keep it as simple as it is now, but make it play nicely with other tools.
This reminds me of how you used to be able to disable the cypher on SSH and now you can't. I hate that.<p><a href="http://serverfault.com/questions/116875/how-can-i-disable-encryption-on-openssh" rel="nofollow">http://serverfault.com/questions/116875/how-can-i-disable-en...</a>
Hehe, The first thing I wrote when I learned programming ( around 1990 ) was a tool called ipxcopy which did the same over IPX protocol that we always used at our Lan Parties.
I use (and highly recommend) <i>IP Messenger</i> for this style of auto-discovery of other systems on your LAN and message/file transfer:<p><a href="http://ipmsg.org/index.html.en" rel="nofollow">http://ipmsg.org/index.html.en</a> (For Windows)<p><a href="http://ishwt.net/en/software/ipmsg/" rel="nofollow">http://ishwt.net/en/software/ipmsg/</a> (For Mac)
Definitely a interesting take on sharing data over a LAN but I would be worried about the repercussions of using broadcasts to move a large quantity of data on a larger network, cool for smaller/personal networks though.
One of the ideas I have since I was a kid, was a graphical way to copy files between computers.<p>Something like you just drag for the extreme left of right border, and sunddenly, the file is being transferred for the other computer.
The example in the README could be better if the command prompt showed that you were on different hosts. As it stands, it seems that you sent it from host 'heisenberg' to host 'heisenberg'.