Check These Out
If you are in ex mode in vim i.e. you've pressed ':'. You can edit the current command by pressing <ctrl-f>
Based on the execute with timeout command in this site.
A more complex script:
#!/bin/sh
# This script will check the avaliability of a list of NFS mount point,
# forcing a remount of those that do not respond in 5 seconds.
#
# It basically does this:
# NFSPATH=/mountpoint TIMEOUT=5; perl -e "alarm $TIMEOUT; exec @ARGV" "test -d $NFSPATH" || (umount -fl $NFSPATH; mount $NFSPATH)
#
TIMEOUT=5
SCRIPT_NAME=$(basename $0)
for i in $@; do
echo "Checking $i..."
if ! perl -e "alarm $TIMEOUT; exec @ARGV" "test -d $i" > /dev/null 2>&1; then
echo "$SCRIPT_NAME: $i is failing with retcode $?."1>&2
echo "$SCRIPT_NAME: Submmiting umount -fl $i" 1>&2
umount -fl $i;
echo "$SCRIPT_NAME: Submmiting mount $i" 1>&2
mount $i;
fi
done
Stuck behind a restrictive firewall at work, but really jonesing to putty home to your linux box for some colossal cave? Goodness knows I was...but the firewall at work blocked all outbound connections except for ports 80 and 443. (Those were wide open for outbound connections.) So now I putty over port 443 and have my linux box redirect it to port 22 (the SSH port) before it routes it internally. So, my specific command would be:
$iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 22
Note that I use -A to append this command to the end of the chain. You could replace that with -I to insert it at the beginning (or at a specific rulenum).
My linux box is running slackware, with a kernel from circa 2001. Hopefully the mechanics of iptables haven't changed since then. The command is untested under any other distros or less outdated kernels.
Of course, the command should be easy enough to adapt to whatever service on your linux box you're trying to reach by changing the numbers (and possibly changing tcp to udp, or whatever). Between putty and psftp, however, I'm good to go for hours of time-killing.
Appends the input file with the date format YYYY-MM-DD.bak. Also runs silently if you remove the -v on the cp at the end of the function.
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"
Continue a current job in the background and detach it from current terminal
Shows all block devices in a tree with descruptions of what they are.
credit shall fall to this for non-gzipped version:
https://gist.github.com/marcanuy/a08d5f2d9c19ba621399