fixes
This commit is contained in:
parent
75cb7fc69a
commit
53f66c53eb
26
README.md
26
README.md
|
@ -1,5 +1,31 @@
|
||||||
# taft — Totally Adequate File Transfer
|
# taft — Totally Adequate File Transfer
|
||||||
|
|
||||||
A simple wrapper around nc(1) and tar(1).
|
A simple wrapper around nc(1) and tar(1).
|
||||||
|
taft's main focus is speed, so no encryption is involved, to minimize overhead.
|
||||||
|
If you're looking for a *secure* way to transfer files, go with sftp(1) instead.
|
||||||
|
|
||||||
*Named after William Howard Taft, [America's greatest president by volume](https://idlewords.com/talks/website_obesity.htm)*.
|
*Named after William Howard Taft, [America's greatest president by volume](https://idlewords.com/talks/website_obesity.htm)*.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Destination host:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mkdir destination; cd destination
|
||||||
|
$ taft receive
|
||||||
|
```
|
||||||
|
|
||||||
|
Source host:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mkdir source; cd source
|
||||||
|
$ touch a b c
|
||||||
|
$ taft send 192.168.178.42 # destination IP address
|
||||||
|
./
|
||||||
|
./c
|
||||||
|
./b
|
||||||
|
./a
|
||||||
|
```
|
||||||
|
|
||||||
|
The default port is 1337.
|
||||||
|
It can be changed via the `-p` or `--port` option.
|
||||||
|
|
41
taft
41
taft
|
@ -22,6 +22,8 @@ port=1337
|
||||||
path=.
|
path=.
|
||||||
tarflags=()
|
tarflags=()
|
||||||
ncflags=()
|
ncflags=()
|
||||||
|
verbose=false
|
||||||
|
compress=none
|
||||||
while true; do
|
while true; do
|
||||||
case $1 in
|
case $1 in
|
||||||
(-p | --port)
|
(-p | --port)
|
||||||
|
@ -33,13 +35,26 @@ while true; do
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
(-v | --verbose)
|
(-v | --verbose)
|
||||||
tarflags+=(--verbose)
|
verbose=true
|
||||||
ncflags+=(-v)
|
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
(-c | --compress)
|
(-c | --compress)
|
||||||
algo=$2
|
compress=$2
|
||||||
case $algo in
|
shift 2
|
||||||
|
;;
|
||||||
|
(--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if "$verbose"; then
|
||||||
|
tarflags+=(--verbose --verbose)
|
||||||
|
ncflags+=(-v)
|
||||||
|
fi
|
||||||
|
|
||||||
|
case $compress in
|
||||||
(none)
|
(none)
|
||||||
;;
|
;;
|
||||||
(xz)
|
(xz)
|
||||||
|
@ -51,15 +66,7 @@ while true; do
|
||||||
(*)
|
(*)
|
||||||
error 'invalid compression algorithm'
|
error 'invalid compression algorithm'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
(--)
|
|
||||||
shift
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if (( $# == 0 )); then
|
if (( $# == 0 )); then
|
||||||
error 'a subcommand is required'
|
error 'a subcommand is required'
|
||||||
|
@ -68,7 +75,7 @@ fi
|
||||||
subcommand=$1
|
subcommand=$1
|
||||||
|
|
||||||
case $subcommand in
|
case $subcommand in
|
||||||
(send)
|
(s | send)
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if (( $# < 1 )); then
|
if (( $# < 1 )); then
|
||||||
|
@ -81,16 +88,16 @@ case $subcommand in
|
||||||
|
|
||||||
dest=$1
|
dest=$1
|
||||||
|
|
||||||
tar --create "${tarflags[@]}" -- "$path" | nc -q 1 "${ncflags[@]}" -- "$dest" "$port"
|
tar --verbose --create "${tarflags[@]}" -- "$path" | nc -q 1 "${ncflags[@]}" -- "$dest" "$port"
|
||||||
;;
|
;;
|
||||||
(recv | receive)
|
(r | recv | receive)
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if (( $# > 0 )); then
|
if (( $# > 0 )); then
|
||||||
error 'too many arguments'
|
error 'too many arguments'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nc -q 1 -l -p "$port" "${ncflags[@]}" | tar --extract "${tarflags[@]}"
|
nc -q 1 -l -p "$port" "${ncflags[@]}" | tar --verbose --extract "${tarflags[@]}"
|
||||||
;;
|
;;
|
||||||
(*)
|
(*)
|
||||||
error 'invalid subcommand'
|
error 'invalid subcommand'
|
||||||
|
|
Loading…
Reference in a new issue