[ create a new paste ] login | about

Link: http://codepad.org/Pbboejn3    [ raw code | fork ]

Plain Text, pasted on Oct 28:
#!/bin/bash

declare port
declare recdir
declare host="0.0.0.0"

function srvtrace {
    time=$(date +%X)
    echo "[srv:$port ($time)] $@" >&2
}

if [[ $2 ]]; then
    port="$1"
    recdir="$2"
    if [[ ! -d "$recdir" ]]; then
        srvtrace "Creating directory '$recdir'"
        mkdir -p "$recdor"
    fi
    srvtrace "Listening at http://$host:$port/"
    srvtrace "Send files via:"
    srvtrace "   tar -c /path/to/file | nc $host $port"
    while true; do
        nc -l $port | tar -xvf - -C "$recdir"
    done
else
    echo "Usage: $0 <port> <recdir>"
fi




Create a new paste based on this one


Comments: