Archive for the ‘unix’ Category.
April 5, 2013, 12:22 pm
This morning a discussion with a friend about various shells lead me to think it would be nice if my bash shell could tab complete hostnames from .ssh/known_hosts when I type ‘ssh <tab>’. I soon found this blog post which nicely documents how to do it. I made a directory in $HOME called .bash.completion and then added this to my .profile, which loops round any files in there, sourcing them individually:
if [ -d ${HOME}/.bash.completion ]; then
for file in ${HOME}/.bash.completion/* ; do
source $file
done
fiAll sorted. However, it wasn’t long before I discovered that ‘ssh user@<tab>’ doesnt work, I tend to use this quite a lot so wanted to see if I could fix up the bash function to support that use case. Bit of hacking around and I’ve got it working, the replacement ssh-completion file is shown below:
# Add bash completion for ssh: it tries to complete the host to which you
# want to connect from the list of the ones contained in ~/.ssh/known_hosts
__ssh_known_hosts() {
if [[ -f ~/.ssh/known_hosts ]]; then
cut -d " " -f1 ~/.ssh/known_hosts | cut -d "," -f1
fi
}
_ssh() {
local cur known_hosts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
known_hosts="$(__ssh_known_hosts)"
if [[ ! ${cur} == -* ]] ; then
if [[ ${cur} == *@* ]] ; then
COMPREPLY=( $(compgen -W "${known_hosts}" -P ${cur/@*/}@ -- ${cur/*@/}) )
else
COMPREPLY=( $(compgen -W "${known_hosts}" -- ${cur}) )
fi
fi
return 0
}
complete -o bashdefault -o default -o nospace -F _ssh ssh 2>/dev/null \
|| complete -o default -o nospace -F _ssh sshHappy.
March 7, 2011, 2:40 pm
This little problem hit me at the weekend, it turns out the fix is trivial but it took me a while reading through the docs to get things working in a way I was completely happy with.
I use the IPTC Headline field in my image management software for the title of the image, this has always worked ok for me and the Flickr upload I use works fine with it. But just recently I have started to use the excellent NextGEN gallery plugin for WordPress. This seems to use the XMP field Title instead of IPTC Headline. I’m not up for changing what I use in the photo management software so I figured I must be able to write one field into another in the meta data.
It turns out exiftool can now manipulate a lot more than just exif data! I don’t think I’ve had any reason to use it to probably 5 years or more. It can easily copy one field to another within the same image, the command line I use is:
exiftool -tagsfromfile %f.jpg -ext jpg -"IPTC:headline>XMP:title" \
-overwrite_original <directory>
This command tells exiftool to read the tags from all the images with the jpg extension in the named directory, and then replace the XMP:title tag with the contents of IPTC:headline. The final option “-overwrite_original” dispenses with the backup copies exiftool normally creates. You might not want to use this, but in my workflow the images I’m processing with this are exports of the originals, not the originals. So if anything screws up I simply have to export them again.
I’m terrible at remembering syntax, so I’ve wrapped this command in a quick bash script which is below incase it is of any use.
#!/bin/bash
[ -z $1 ] && echo "Must provide a directory name, . is acceptable" && exit 1
[ ! -d $1 ] && echo "$1 is not a directory" && exit 1
# Run exiftool and copy IPTC Headline to XMP Title for everything in given dir
exiftool -tagsfromfile %f.jpg -ext jpg -"IPTC:headline>XMP:title" \
-overwrite_original $1 |
November 16, 2005, 12:23 pm
I found this great page whilst looking for something else. It gives some ideas about how to block brute force attacks using recent iptables.
March 2, 2005, 11:40 am
Add the following to /etc/X11/Xresources and restart X / [gkx]dm
xterm*VT100.Translations: #override
BackSpace: string(0x7F)n
Delete: string("
Home: string("
End: string("
*ttyModes: erase ^?
Tested on RHEL3.
Thanks to Justin for this
November 17, 2004, 11:26 am
Found this nice collection of daemontools run scripts. Will find that useful someday
May 24, 2004, 5:04 am
Found this nice page with scripts and configs for parsing the apache server-status page and using mrtg to graph them
March 24, 2004, 11:21 am
Ells posted a nice site which details some of the features of screen, here
December 22, 2003, 1:55 am
I’ve just found this quite usefull in setting up amanda to do disk only backups.
November 27, 2003, 9:51 am
Found this page, has some usefull information wrt single use keys
August 1, 2003, 4:09 am
Rather than using the qmail-queue patch and qmail-scanner to get Spam Assassin working with qmail this page suggests replacing qmail-queue with a simple sh script.
Seems to work on our internal work server, but of course you would need to put qmail-scanner in to check for viri.