I’ve been using Swatch for quite a while now and I never invested the time to create a quick startup script. Today, I decided to create one and it works just fine under Centos and Ubuntu Server. You can download it here..
swatch init script == Download
Bash Tutorial
BASH
We’ve all heard of shell programming, but in the end what we write are simple scripts composed of strung-together commands, performing simple operations in a more-or-less linear manner. But the shell can do much more than what we tend to ask of it.
bash is, in my opinion, the most powerful shell on the market that doesn’t require you to be a programmer to use it. On the other hand, for those who want to learn to program it, rather than just script it, its sound principles and powerful features offer a wealth of opportunity for writing fast, flexible programs that can often out-perform most other interpreted languages.
This is a very informal crash tutorial in intermediate features of shell programming. It assumes a basic grasp of programming principles and of simple, beginner-level shell scripting.
Continue reading “Bash Tutorial” »
Generate MAC addresses for XEN using shell
#!/bin/bash
# Generate unique valid XEN MAC addresses in shell, ’cause it’s faster
# Xen MAC’s begin with 00:16:3e
declare -i num=”${1:-0}”
until [[ $num -gt 0 ]]; do
read -p “How many MAC’s do you want to generate? ” num
done
declare -a macs=( )
while [[ $num -gt 0 ]]; do
mac=$(printf ‘%02x:%02x:%02x’ $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256)))
for i in “${macs[@]}”; do
[[ $mac = $i ]] && continue 2
done
macs[${#macs[*]}]=$mac
echo 00:16:3e:$mac
num=$((num-1))
done
idoit – Run commands based on input records
#!/bin/bash
# Execute commands locally or remotely based on fields in records.
# Only supports single-character record separators, but field delimiters may be
# many characters (and that's probably a good idea).
# Author: Christopher Hahn, Apr 2008
Continue reading “idoit – Run commands based on input records” »