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
|
||||
|
||||
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)*.
|
||||
|
||||
## 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=.
|
||||
tarflags=()
|
||||
ncflags=()
|
||||
verbose=false
|
||||
compress=none
|
||||
while true; do
|
||||
case $1 in
|
||||
(-p | --port)
|
||||
|
@ -33,13 +35,26 @@ while true; do
|
|||
shift 2
|
||||
;;
|
||||
(-v | --verbose)
|
||||
tarflags+=(--verbose)
|
||||
ncflags+=(-v)
|
||||
verbose=true
|
||||
shift
|
||||
;;
|
||||
(-c | --compress)
|
||||
algo=$2
|
||||
case $algo in
|
||||
compress=$2
|
||||
shift 2
|
||||
;;
|
||||
(--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if "$verbose"; then
|
||||
tarflags+=(--verbose --verbose)
|
||||
ncflags+=(-v)
|
||||
fi
|
||||
|
||||
case $compress in
|
||||
(none)
|
||||
;;
|
||||
(xz)
|
||||
|
@ -51,15 +66,7 @@ while true; do
|
|||
(*)
|
||||
error 'invalid compression algorithm'
|
||||
;;
|
||||
esac
|
||||
shift 2
|
||||
;;
|
||||
(--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
esac
|
||||
|
||||
if (( $# == 0 )); then
|
||||
error 'a subcommand is required'
|
||||
|
@ -68,7 +75,7 @@ fi
|
|||
subcommand=$1
|
||||
|
||||
case $subcommand in
|
||||
(send)
|
||||
(s | send)
|
||||
shift
|
||||
|
||||
if (( $# < 1 )); then
|
||||
|
@ -81,16 +88,16 @@ case $subcommand in
|
|||
|
||||
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
|
||||
|
||||
if (( $# > 0 )); then
|
||||
error 'too many arguments'
|
||||
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'
|
||||
|
|
Loading…
Reference in a new issue