Simple Improvements for Simple Scripts

Did you ever suddenly notice that something simple you've been doing for years could be vastly improved with just a little bit of tweaking? I did yesterday concerning the transfer of files with netcat (e.g. when nobody got sendfile installed and standard paranoia forbids simply using scp instead) and figured I should share my sudden “enlightenment” ;-)

ncsend

#!/bin/sh
 
host=$1
shift
 
tar cv "$@" | pv -brt | nc -q0 $host 23000

ncrecv

#!/bin/sh
 
netcat -l -p 23000 | pv -brt | tar xv

Note: piping to pv is optional

Edit: fixed a word splitting bug and specified a default port

Linkbacks

blog:2008:04:the_quest_for_the_perfect_htpc, 2008/04/13 19:46 (Trackback)
 

Discussion

Andreas GohrAndreas Gohr, 2008/03/29 10:09

Paranoia against using scp? What's wrong with scp?

demoddemod, 2008/03/29 10:35

What I meant was that a lot of people don't want to enter their ssh passwords on a machine not their own; even when there is absolutely no reason to believe that there is a keylogger running.

Enter your comment (wiki syntax is allowed):
FIPWD
blog/2008/03/netcat.txt · Last modified: 2008/08/16 21:03 by demod