Check These Out
can be used within a script to configure iptables for example:
iface=$2
inet_ip=`ifconfig "$iface" | grep inet | cut -d: -f2 | cut -d ' ' -f1`
ipt="sudo /sbin/iptables"
.........................
----------------------------------------------------------------------------------------------------------------
$ipt -A INPUT -i $iface ! -f -p tcp -s $UL -d $inet_ip --sport 1023: --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
----------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
$ipt -A OUTPUT -o $iface -p tcp -s $inet_ip -d $UL --sport 3306 --dport 1023: -m state --state ESTABLISHED,RELATED -j ACCEPT
-----------------------------------------------------------------------------------------------------------------
Converts any number of seconds into days, hours, minutes and seconds.
sec2dhms() {
declare -i SS="$1"
D=$(( SS / 86400 ))
H=$(( SS % 86400 / 3600 ))
M=$(( SS % 3600 / 60 ))
S=$(( SS % 60 ))
[ "$D" -gt 0 ] && echo -n "${D}:"
[ "$H" -gt 0 ] && printf "%02g:" "$H"
printf "%02g:%02g\n" "$M" "$S"
}
A quick alias I use right before logging into a server so that I have a log of the transactions as well as the ability to re-connect from another computer. Useful for when your boss says "what commands did you run again on that server?" and you had already closed the terminal ;)
I wrapped it in a script now, with more features, but this is the heart of it.
Never leave home without it.
connect to it with any network command (including web browser - if you don't mind weird formatting)
curl 127.0.0.1:9876
nc 127.0.0.1 9876
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"
Solves "tr" issues with non C-locales under BSD-like systems (like OS X)
This is similar to standard `pv`, but it retains the rate history instead of only showing the current rate. This is useful for spotting changes.
To do this, -f is used to force pv to output, and stderr is redirected to stdout so that `tr` can swap the carriage returns for new lines.
(doesn't work correctly is in zsh for some reason. Tail's output isn't redirected to /dev/null like it is in bash. anyone know why? ???????)
The arguments of "seq" indicate the starting value, step size, and the end value of the x-range. "awk" outputs (x, f(x)) pairs and pipes them to "graph", which is part of the "plotutils" package.