TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Quickly copy a file between computers

110 pointsby diginuxover 12 years ago
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.

19 comments

midnightsineover 12 years ago
$ nc -l 8888 &#62; 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.
评论 #5231975 未加载
评论 #5231984 未加载
评论 #5231965 未加载
评论 #5232604 未加载
评论 #5232466 未加载
评论 #5232164 未加载
评论 #5232013 未加载
评论 #5232277 未加载
评论 #5233842 未加载
评论 #5232938 未加载
评论 #5232827 未加载
jbesterover 12 years ago
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.
评论 #5232405 未加载
kylecordesover 12 years ago
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>
评论 #5232793 未加载
abcd_fover 12 years ago
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(&#38;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.
评论 #5232397 未加载
dclowd9901over 12 years ago
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?
评论 #5232400 未加载
frosephover 12 years ago
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.
评论 #5234657 未加载
评论 #5232446 未加载
latitudeover 12 years ago
Try and add support for detecting piped input on the server side:<p><pre><code> bcp &#60; 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 &#62; filename </code></pre> Keep it as simple as it is now, but make it play nicely with other tools.
评论 #5232678 未加载
评论 #5232816 未加载
cowmixover 12 years ago
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>
评论 #5232592 未加载
评论 #5232217 未加载
xalover 12 years ago
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.
f1codzover 12 years ago
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)
jamescunover 12 years ago
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.
评论 #5232216 未加载
dudurochaover 12 years ago
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.
评论 #5232413 未加载
pyreover 12 years ago
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'.
评论 #5232139 未加载
评论 #5232414 未加载
dredmorbiusover 12 years ago
Reminds me of <a href="http://www.advogato.org/article/555.html" rel="nofollow">http://www.advogato.org/article/555.html</a>
评论 #5232500 未加载
bltover 12 years ago
python -m SimpleHTTPServer<p>is another nice way to do this.
评论 #5232441 未加载
donflamencoover 12 years ago
Zmodem (rz/sz) works if your terminal supports it. Though putty doesn't support it (wish it did.)
sebkomianosover 12 years ago
Title should be "between computers on a lan".
dschiptsovover 12 years ago
scp?)
huhsamovarover 12 years ago
$ scp file host.example.com:
评论 #5232160 未加载
评论 #5232393 未加载
评论 #5232434 未加载