I just thought I'd post this incase anyone else found it useful. I wrote it mainly to save typing out users and hosts for ssh connections but left it so it could be used for running any sort of command.
All you need to do is put the floowing script into a file called "/usr/local/bin/go", or anywhere else in your path.
Code:
#!/bin/bash
if [ -r ~/.go ] && [ ! $1 ];then
OLDIFS=$IFS
IFS="
"
num=0
choice=1
while [ $choice -lt 1 ] || [ $choice -gt $((num-1)) ];do
a=1
num=1
echo " Please choose a command number below"
for line in `cat ~/.go`;do
if [ $a -eq 1 ];then
command[$num]=$line
a=2
else
echo " $num) $line"
a=1
num=$((num+=1))
fi
done
echo -n " Enter your selection: "
read choice
echo
IFS=$OLDIFS
${command[$choice]}
done
else
echo You do not appear to have a \~/.go config file or it is not readable
echo \~/.go files should consist of 2 lines, the first being the command
echo and the second being the description that is used by the go script.
echo
echo Version 1, Written by David Ross http://www.rossy.co.uk
fi
Then make it executable:
chmod 755 /usr/local/bin/go
You then need a basic configuration file called ".go" in your home directory. The file takes the structure:
Code:
command 1
Description of command 1
command 2
Description of command 2
and so on... You should end up with a file like
Code:
ssh root@server.mydomain.com
SSH as root to my server
ssh webmaster@server.mydomain.com
SSH as webmaster to my server
/home/user/backup.sh
Run backup script
I hope you find it useful
.