nicely rearranged into a meaningful examples folder, which now provides
authorChris Koeritz <fred@gruntose.com>
Wed, 25 Jan 2012 07:37:52 +0000 (02:37 -0500)
committerChris Koeritz <fred@gruntose.com>
Wed, 25 Jan 2012 07:37:52 +0000 (02:37 -0500)
a good storage area for the example custom scripts.  whew.  trying to
override a .gitignore in a subdirectory may be possible, but i couldn't
find out how.  luckily this is a better organization structure anyhow.

24 files changed:
scripts/bashisms/fred_techniques.txt [deleted file]
scripts/bashisms/qs_handy_unix_examples.sh [deleted file]
scripts/custom/examples/fred/c_common_aliases.txt [deleted file]
scripts/custom/examples/fred/c_variables.sh [deleted file]
scripts/custom/examples/fred/java_profile.sh [deleted file]
scripts/custom/examples/readme.txt [deleted file]
scripts/examples/bashisms/fred_techniques.txt [new file with mode: 0644]
scripts/examples/bashisms/qs_handy_unix_examples.sh [new file with mode: 0644]
scripts/examples/bashisms/script_location.sh [new file with mode: 0644]
scripts/examples/bashrc_grover [deleted file]
scripts/examples/bashrc_root [deleted file]
scripts/examples/bashrc_user [deleted file]
scripts/examples/bashrc_user_windoz [deleted file]
scripts/examples/custom_overrides/fred/c_common_aliases.txt [new file with mode: 0644]
scripts/examples/custom_overrides/fred/c_variables.sh [new file with mode: 0644]
scripts/examples/custom_overrides/fred/java_profile.sh [new file with mode: 0644]
scripts/examples/custom_overrides/readme.txt [new file with mode: 0644]
scripts/examples/example_registry_ops.sh [deleted file]
scripts/examples/feisty_meow_startup/bashrc_grover [new file with mode: 0644]
scripts/examples/feisty_meow_startup/bashrc_root [new file with mode: 0644]
scripts/examples/feisty_meow_startup/bashrc_user [new file with mode: 0644]
scripts/examples/feisty_meow_startup/bashrc_user_windoz [new file with mode: 0644]
scripts/examples/os_related/example_registry_ops.sh [new file with mode: 0644]
scripts/examples/script_location.sh [deleted file]

diff --git a/scripts/bashisms/fred_techniques.txt b/scripts/bashisms/fred_techniques.txt
deleted file mode 100644 (file)
index c841a89..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-
-##############
-#  Name   : fred_techniques
-#  Author : Chris Koeritz
-#  Rights : Copyright (C) 2010-$now by Author
-##############
-# Copyright (c) 2010-$now By Author.  This script is free software; you can
-# redistribute it and/or modify it under the terms of the simplified BSD
-# license.  See: http://www.opensource.org/licenses/bsd-license.php
-# Please send updates for this code to: fred@gruntose.com -- Thanks, fred.
-##############
-
-# this script is a collection of helpful bash practices that unfortunately
-# sometimes slip my mind when i need them.  it's intended to collect all the
-# good bits so they don't slip away.  feel free to re-use them in your own
-# code as needed.
-
-##############
-
-# clean for loops in bash:
-
-for ((i=0; i < 5; i++)) do
-  echo $i
-done
-
-##############
-
-# removing an array element
-# --> only works on arrays that have no elements containing a space character.
-
-# define a 5 element array.
-arr=(a b c d e)
-
-# remove element 2 (the 'c').
-removepoint=2
-
-# set the array to slices of itself.
-arr=(${arr[*]:0:$removepoint} ${arr[*]:(($removepoint+1))} )
-
-# show the new contents.
-echo ${arr[*]}
-# shows: a b d e
-
-##############
-
-# store to a variable name by derefercing it.
-
-# shows how you can store into a variable when you are given only its name.
-function store_to_named_var()
-{
-  local name="$1"; shift
-  eval ${name}=\(gorbachev "perestroikanator 12000" chernenko\)
-}
-
-declare -a ted=(petunia "butter cup" smorgasbord)
-echo ted is ${ted[@]}
-store_to_named_var ted
-echo ted is now ${ted[@]}
-
-##############
-
diff --git a/scripts/bashisms/qs_handy_unix_examples.sh b/scripts/bashisms/qs_handy_unix_examples.sh
deleted file mode 100644 (file)
index 5293f3b..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-#!/bin/bash
-
-#
-# these great examples of handy unix tidbits were donated by "q. black".
-#
-
-# list a directory tree
-ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'
-
-# list directory sizes (biggest first)
-du -h $(du -s * |sort -nr|awk '{print $2}')
-
-# this will sort a date field of the form: DD-MON-YYYY HH:MM:SS
-sort +0.7 -1 +0.3M -0.6 +0 -0.2 +1
-
-# this will sort a date field of the form: MON DD HH:MM:SS YYYY
-sort +3 -4 +0M +1n
-
-# this will sort a date field of the form: MON DD HH:MM:SS
-sort +0M +1n
-# this will sort a date field of the form: Date: Tue Feb  3 09:17:58 EST 2004
-sort +6 -7 +2M +3n +4
-
-# display all lines from a certain line onward
-start_line=132
-|awk "{if (NR >= ${start_line}){print \$0}}"
-
-# display all lines after a token
-sed '1,/CUT HERE/d'
-
-# print the first and last lines
-sed -n '1,1p;$,$p'
-
-# signal bash about a window size change
-kill -winch $$
-
-# show the date 1 year, 2 months and 3 days ago
-date -v -1y -v -2m -v -3d
-
-# set the date back 1 year
-sudo date $(date -v -1y +%Y%m%d%H%M)
-
-# output the standard date format for setting the time
-# get the date
-date -u +%Y%m%d%H%M.%S
-# set the date
-date -u (cut and paste from above)
-
-# convert one date format to another (output is in the current time zone)
-old_date="Aug 27 15:24:33 2005 GMT"
-new_date=$(date -j -f "%b %e %T %Y %Z" "${old_date}" +%D)
-echo ${new_date}
-# returns "08/27/05"
-
-# output the modification time of a file in different format
-file=
-date -j -f "%b %e %T %Y" "$(ls -lT ${file} |awk '{print $6,$7,$8,$9}')"
-
-# output the number of days until a certain date
-target_date="Sep  2 15:20:20 2005 GMT"
-target_seconds=$(date -j -f "%b %e %T %Y" +%s "${target_date}" 2>/dev/null)
-diff_seconds=$(expr ${target_seconds} - $(date +%s))
-diff_days=$(expr ${diff_seconds} / 86400)
-echo "${diff_days} day(s)"
-
-# these commands can be used to fill in missing times in a "uniq -c" count
-# of times.
-# output 24 hours in one minute increments
-for h in $(jot -w %02d - 0 23 1); do
-    for m in $(jot -w %02d - 0 59 1); do
-       echo "   0 ${h}:${m}"
-    done
-done
-# sort them together, and remove any 0 counts if an count already exists
-sort +1 +0rn out1 out2 |uniq -f 1
-
-# output with w3m to get basic html word wrap
-w3m -T "text/html" -dump -cols 72 <<EOF
-    <p>
-    This test verifies basic networking and that the ${product_short_name}
-    can reach it's default gateway.
-EOF
-
-# another way to format text for output
-fmt 72 <<EOF
-This test verifies basic networking and that the ${product_short_name}
-can reach it's default gateway.
-EOF
-
-# smtpcrypt "printf"
-{
-char *jkwbuf = NULL;
-asprintf(&jkwbuf, "JKW: msg->used = %ld\n", msg->used);
-BIO_write(sc->log, jkwbuf, strlen(jkwbuf)+1);
-free(jkwbuf);
-}
-
-# rolling diff of a list of files (diff a & b, then b & c,...)
-last=
-for i in $(ls -1rt); do
-    if [ ! -z "${last}" ]; then
-       diff -u ${last} ${i}
-    fi
-    last=${i}
-done
-
-# clearing and restoring chflags
-file=
-old_chflags=$(ls -lo ${file}|awk '{print $5}')
-chflags 0 ${file}
-# do whatever
-if [ ."${old_chflags}" != ."-" ]; then
-    chflags ${old_chflags} ${file}
-fi
-
-# way to do standard edits to files
-file=
-{
-    # append line(s) after a line, "i" to insert before
-    echo '/www_recovery/a'
-    echo 'mithril ALL = (root) NOPASSWD: /usr/local/libexec/destroyer'
-    echo '.'
-    # modify a line
-    echo 'g/^xntpd_program=/s,^xntpd_program=.*$,xntpd_program="ntpd",'
-    # delete a line
-    echo 'g/^controls key secret =/d'
-    echo 'x!'
-} | ex - ${file}
-
-# how to search for errors in the last 24 hours
-# note that this command does not work quite right.  The sort is off early
-# in the year because the dates do not have the year.
-# Also sed never sees the /CUT HERE/ when it is the first line.
-(echo "$(date -v-24H "+%b %e %H:%M:%S") --CUT HERE--"; \
-    zgrep -h "cookie" /var/log/messages*)|sort +0M| \
-    sed '1,/CUT HERE/d'
-# This version fixes those problems.  It adds the file year to the date
-# and puts a marker at the start of the list.
-(echo "$(date -j -f "%s" 0 "+%Y %b %e %H:%M:%S") --ALWAYS FIRST--"; \
-    echo "$(date -v-24H "+%Y %b %e %H:%M:%S") --CUT HERE--"; \
-    for i in /var/log/messages*; do
-       year=$(ls -lT ${i}|awk '{print $9}')
-       zgrep -h "cookie" ${i}|while read line; do
-           echo "${year} ${line}"
-       done
-    done)|sort +0n +1M| sed '1,/CUT HERE/d'
-
-# process a list of quoted values
-{
-    # It tends to be easiest to use a 'here-document' to feed in the list.
-    # I prefer to have the list at the start instead of the end
-    cat <<EOF
-       'general' 'network node0' 'private address'
-       'general' 'options node2' 'kern securelevel'
-EOF
-}| while read line; do
-    eval set -- ${line}
-    config=$1; shift
-    section=$1; shift
-    key=$1; shift
-
-    echo "confutil value \"${config}\" \"${section}\" \"${key}\""
-done
-
-# Method to read lines with a "for" loop, without spawning a subshell
-NEWLINE='
-'
-OIFS="${IFS}"
-IFS="${NEWLINE}"
-for line in $(cat /etc/passwd | sort -r); do
-    IFS="${OIFS}"
-
-    # do whatever you want here
-    echo "line = ${line}"
-
-    IFS="${NEWLINE}"
-done
-IFS="${OIFS}"
-
-# generate a histogram of characters in a file
-cat file|
-    awk '{for (i=1; i <= length($0); i++) {printf("%s\n",substr($0,i,1))}}'|
-    sort|uniq -c
-
-# show line lengths for a file
-cat file| awk '{print length($0)}'| sort -n
-
-
-
-
-# get the modification time of a directory or file and then reset the time.
-target=/usr/local/etc/pkdb
-save_date=$(ls -ldT ${target}|awk '{print $6,$7,$8,$9}')
-save_date=$(date -j -f "%b %e %T %Y" "${save_date}" +"%Y%m%d%H%M.%S")
-# later
-touch -t ${save_date} ${target}
-
-
-# detect NULL bytes in a file
-file=
-hexdump -e '"%_u\n"' ${file}|grep -q '^nul$'
-if [ $? -eq 0 ]; then
-else
-fi
-
-
-# calculate average
-cd /tmp
-uudecode
-begin 644 bc.average
-M<V-A;&4],PIT;W1A;#TP"F-O=6YT/3`*=VAI;&4@*#$I('L*("`@(&YU;2`]
-M(')E860H*0H@("`@:68@*&YU;2`]/2`P*2!B<F5A:SL*("`@(&-O=6YT*RL*
-M("`@('1O=&%L("L](&YU;0I]"B)T;W1A;"`]("([('1O=&%L"B)C;W5N="`]
-K("([(&-O=6YT"B)A=F5R86=E(#T@(CL@=&]T86P@+R!C;W5N=`IQ=6ET"@``
-`
-end
-(cat data; echo "0") |bc -q bc.average
-
-
diff --git a/scripts/custom/examples/fred/c_common_aliases.txt b/scripts/custom/examples/fred/c_common_aliases.txt
deleted file mode 100644 (file)
index ec8c5fa..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-
-moo='check_mount /z/stuffing ; check_mount /z/walrus ; check_mount /z/chunky '
-unmoo='umount /z/stuffing ; umount /z/walrus ; umount /z/chunky '
-
-refred='(chowngrp -R fred /home/fred /usr/local/games /home/archives /fatty /clutterato /var/spool/mail/fred ; normal_perm /var/log )'
-
-
-
diff --git a/scripts/custom/examples/fred/c_variables.sh b/scripts/custom/examples/fred/c_variables.sh
deleted file mode 100644 (file)
index 022f1cb..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-
-# these are my personal overrides.  --fred.
-
-# The quartz directory has *really* personalized items.
-export QUARTZDIR=$HOME/quartz
-
-# The gruntose web site is expected to reside below, if it exists at all.
-export WEB_DIR=$HOME/web
-if [ "$(hostname)" = "zooty.koeritz.com" ]; then
-  export WEB_DIR=/var/www
-fi
-
-# point to our local certificate for ssh usage.
-export SVN_SSH="ssh -i $HOME/.ssh/id_dsa_sourceforge"
-
-# Error and success noises for CLAM.
-export CLAM_ERROR_SOUND='/z/walrus/media/sounds/effects/bwaaang.wav /z/walrus/media/sounds/cartoons/doh4.wav'
-export CLAM_FINISH_SOUND='/z/walrus/media/sounds/cartoons/meepmeep.wav'
-
-# Setup for nethack adventure.
-export NETHACKOPTIONS='name:Manjusri-W,dogname:Fred,catname:Zonker'
-
-# mail setup for home machines.
-export REPLYTO=fred@gruntose.com
-export from="Fred T. Hamster <fred@gruntose.com>"
-
-# set our browser for seti and others that use the variable.
-export BROWSER=/usr/bin/firefox
-
-# editor and other mixed settings...
-export VISUAL=$(which vim)
-
-#hmmm: move these to the uva profile,
-#      rename uva profile to java profile,
-#      get them doing the right thing per OS.
-#  export JAVA_HOME="c:/Program Files/java/jdk1.6.0_11"
-
-# special settings for win32 and svn.
-if [ "$OS" == "Windows_NT" ]; then
-  export EDITOR=$(which gvim)
-fi
-
-# this hideous mess is necessitated by our not having found the source of the
-# settings yet.  we override a few colors that look bad on a dark background.
-export LS_COLORS='no=00:fi=00:di=01;37:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;35:*.rpm=00;33:*.deb=00;33:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;35:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;35:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:'
-
-# we set this to avoid paying for slow app signing on win32.
-export NO_SIGNING=true
-
diff --git a/scripts/custom/examples/fred/java_profile.sh b/scripts/custom/examples/fred/java_profile.sh
deleted file mode 100644 (file)
index 7186b44..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/bin/bash
-# this script tries to intuit where java is installed on this machine.
-
-############################
-
-function intuition_failure()
-{
-  missing="$1"; shift
-  echo "We cannot intuit your $missing variable for this host."
-  # remove the variable because its value is busted.
-  unset $missing
-}
-
-############################
-
-# set some fairly liberal limits for ant.
-export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m"
-
-############################
-
-# start guessing some settings...
-
-# this bin portion works for most javas...
-export JAVA_BIN_PIECE=bin
-
-if [ ! -d "$JAVA_HOME" ]; then
-  # first try a recent linux version.
-  export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
-fi
-if [ ! -d "$JAVA_HOME" ]; then
-  # try using a windows version.
-#note: this logic is untested.
-# probably will break due to space in path issues.
-  declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jdk" 2>/dev/null)
-  if [ ${#any_there[*]} -gt 0 ]; then
-    (( last = ${#any_there[@]} - 1 ))
-    JAVA_HOME="${any_there[$last]}"
-  fi
-  if [ ! -d "$JAVA_HOME" ]; then
-    # if no jdk, try a jre.
-    declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jre" 2>/dev/null)
-    if [ ${#any_there[*]} -gt 0 ]; then
-      (( last = ${#any_there[@]} - 1 ))
-      JAVA_HOME="${any_there[$last]}"
-    fi
-  fi
-fi
-# this should go last, since it changes the bin dir.
-if [ ! -d "$JAVA_HOME" ]; then
-  # if that didn't work, try the location for mac os x.
-  JAVA_HOME=/Library/Java/Home
-  JAVA_BIN_PIECE=Commands
-fi
-# last thing is to tell them we couldn't find it.
-if [ ! -d "$JAVA_HOME" ]; then
-  intuition_failure JAVA_HOME
-  unset JAVA_BIN_PIECE
-fi
-
-############################
-
-# intuit where we have our local eclipse.
-if [ ! -d "$ECLIPSE_DIR" ]; then
-  export ECLIPSE_DIR=/usr/local/eclipse_jee
-fi
-if [ ! -d "$ECLIPSE_DIR" ]; then
-  ECLIPSE_DIR=$HOME/eclipse
-fi
-if [ ! -d "$ECLIPSE_DIR" ]; then
-  ECLIPSE_DIR=$HOME/apps/eclipse
-fi
-if [ ! -d "$ECLIPSE_DIR" ]; then
-#uhhh, default on winders?
-  ECLIPSE_DIR="/c/Program Files/eclipse"
-fi
-if [ ! -d "$ECLIPSE_DIR" ]; then
-  ECLIPSE_DIR="/c/tools/eclipse"
-fi
-if [ ! -d "$ECLIPSE_DIR" ]; then
-  ECLIPSE_DIR="/d/tools/eclipse"
-fi
-if [ ! -d "$ECLIPSE_DIR" ]; then
-  ECLIPSE_DIR="/e/tools/eclipse"
-fi
-# final option is to whine.
-if [ ! -d "$ECLIPSE_DIR" ]; then intuition_failure ECLIPSE_DIR; fi
-
-############################
-
-# use the variables we just set in our path, and try to make them override
-# any other paths to different versions.
-
-if [ ! -z "$JAVA_HOME" ]; then
-  export PATH=$JAVA_HOME/$JAVA_BIN_PIECE:$PATH
-fi
-if [ ! -z "$ECLIPSE_DIR" ]; then
-  export PATH=$ECLIPSE_DIR:$PATH
-fi
-
-
diff --git a/scripts/custom/examples/readme.txt b/scripts/custom/examples/readme.txt
deleted file mode 100644 (file)
index e8e14a5..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-this folder has some examples of how various people (or one person right now)
-do their custom scripts.
-
-the scripts often have the same name as the main script's name, but with
-a "c_" in front.  ones understood currently are:
-  c_common_aliases.txt
-  c_sh_aliases.txt
-  c_variables.sh
-
-when you have some custom scripts you want to use, copy them from your own
-folder to the scripts/custom directory.  be careful though, because these
-will never be checked into the repository from there.
-
diff --git a/scripts/examples/bashisms/fred_techniques.txt b/scripts/examples/bashisms/fred_techniques.txt
new file mode 100644 (file)
index 0000000..c841a89
--- /dev/null
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+##############
+#  Name   : fred_techniques
+#  Author : Chris Koeritz
+#  Rights : Copyright (C) 2010-$now by Author
+##############
+# Copyright (c) 2010-$now By Author.  This script is free software; you can
+# redistribute it and/or modify it under the terms of the simplified BSD
+# license.  See: http://www.opensource.org/licenses/bsd-license.php
+# Please send updates for this code to: fred@gruntose.com -- Thanks, fred.
+##############
+
+# this script is a collection of helpful bash practices that unfortunately
+# sometimes slip my mind when i need them.  it's intended to collect all the
+# good bits so they don't slip away.  feel free to re-use them in your own
+# code as needed.
+
+##############
+
+# clean for loops in bash:
+
+for ((i=0; i < 5; i++)) do
+  echo $i
+done
+
+##############
+
+# removing an array element
+# --> only works on arrays that have no elements containing a space character.
+
+# define a 5 element array.
+arr=(a b c d e)
+
+# remove element 2 (the 'c').
+removepoint=2
+
+# set the array to slices of itself.
+arr=(${arr[*]:0:$removepoint} ${arr[*]:(($removepoint+1))} )
+
+# show the new contents.
+echo ${arr[*]}
+# shows: a b d e
+
+##############
+
+# store to a variable name by derefercing it.
+
+# shows how you can store into a variable when you are given only its name.
+function store_to_named_var()
+{
+  local name="$1"; shift
+  eval ${name}=\(gorbachev "perestroikanator 12000" chernenko\)
+}
+
+declare -a ted=(petunia "butter cup" smorgasbord)
+echo ted is ${ted[@]}
+store_to_named_var ted
+echo ted is now ${ted[@]}
+
+##############
+
diff --git a/scripts/examples/bashisms/qs_handy_unix_examples.sh b/scripts/examples/bashisms/qs_handy_unix_examples.sh
new file mode 100644 (file)
index 0000000..5293f3b
--- /dev/null
@@ -0,0 +1,220 @@
+#!/bin/bash
+
+#
+# these great examples of handy unix tidbits were donated by "q. black".
+#
+
+# list a directory tree
+ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'
+
+# list directory sizes (biggest first)
+du -h $(du -s * |sort -nr|awk '{print $2}')
+
+# this will sort a date field of the form: DD-MON-YYYY HH:MM:SS
+sort +0.7 -1 +0.3M -0.6 +0 -0.2 +1
+
+# this will sort a date field of the form: MON DD HH:MM:SS YYYY
+sort +3 -4 +0M +1n
+
+# this will sort a date field of the form: MON DD HH:MM:SS
+sort +0M +1n
+# this will sort a date field of the form: Date: Tue Feb  3 09:17:58 EST 2004
+sort +6 -7 +2M +3n +4
+
+# display all lines from a certain line onward
+start_line=132
+|awk "{if (NR >= ${start_line}){print \$0}}"
+
+# display all lines after a token
+sed '1,/CUT HERE/d'
+
+# print the first and last lines
+sed -n '1,1p;$,$p'
+
+# signal bash about a window size change
+kill -winch $$
+
+# show the date 1 year, 2 months and 3 days ago
+date -v -1y -v -2m -v -3d
+
+# set the date back 1 year
+sudo date $(date -v -1y +%Y%m%d%H%M)
+
+# output the standard date format for setting the time
+# get the date
+date -u +%Y%m%d%H%M.%S
+# set the date
+date -u (cut and paste from above)
+
+# convert one date format to another (output is in the current time zone)
+old_date="Aug 27 15:24:33 2005 GMT"
+new_date=$(date -j -f "%b %e %T %Y %Z" "${old_date}" +%D)
+echo ${new_date}
+# returns "08/27/05"
+
+# output the modification time of a file in different format
+file=
+date -j -f "%b %e %T %Y" "$(ls -lT ${file} |awk '{print $6,$7,$8,$9}')"
+
+# output the number of days until a certain date
+target_date="Sep  2 15:20:20 2005 GMT"
+target_seconds=$(date -j -f "%b %e %T %Y" +%s "${target_date}" 2>/dev/null)
+diff_seconds=$(expr ${target_seconds} - $(date +%s))
+diff_days=$(expr ${diff_seconds} / 86400)
+echo "${diff_days} day(s)"
+
+# these commands can be used to fill in missing times in a "uniq -c" count
+# of times.
+# output 24 hours in one minute increments
+for h in $(jot -w %02d - 0 23 1); do
+    for m in $(jot -w %02d - 0 59 1); do
+       echo "   0 ${h}:${m}"
+    done
+done
+# sort them together, and remove any 0 counts if an count already exists
+sort +1 +0rn out1 out2 |uniq -f 1
+
+# output with w3m to get basic html word wrap
+w3m -T "text/html" -dump -cols 72 <<EOF
+    <p>
+    This test verifies basic networking and that the ${product_short_name}
+    can reach it's default gateway.
+EOF
+
+# another way to format text for output
+fmt 72 <<EOF
+This test verifies basic networking and that the ${product_short_name}
+can reach it's default gateway.
+EOF
+
+# smtpcrypt "printf"
+{
+char *jkwbuf = NULL;
+asprintf(&jkwbuf, "JKW: msg->used = %ld\n", msg->used);
+BIO_write(sc->log, jkwbuf, strlen(jkwbuf)+1);
+free(jkwbuf);
+}
+
+# rolling diff of a list of files (diff a & b, then b & c,...)
+last=
+for i in $(ls -1rt); do
+    if [ ! -z "${last}" ]; then
+       diff -u ${last} ${i}
+    fi
+    last=${i}
+done
+
+# clearing and restoring chflags
+file=
+old_chflags=$(ls -lo ${file}|awk '{print $5}')
+chflags 0 ${file}
+# do whatever
+if [ ."${old_chflags}" != ."-" ]; then
+    chflags ${old_chflags} ${file}
+fi
+
+# way to do standard edits to files
+file=
+{
+    # append line(s) after a line, "i" to insert before
+    echo '/www_recovery/a'
+    echo 'mithril ALL = (root) NOPASSWD: /usr/local/libexec/destroyer'
+    echo '.'
+    # modify a line
+    echo 'g/^xntpd_program=/s,^xntpd_program=.*$,xntpd_program="ntpd",'
+    # delete a line
+    echo 'g/^controls key secret =/d'
+    echo 'x!'
+} | ex - ${file}
+
+# how to search for errors in the last 24 hours
+# note that this command does not work quite right.  The sort is off early
+# in the year because the dates do not have the year.
+# Also sed never sees the /CUT HERE/ when it is the first line.
+(echo "$(date -v-24H "+%b %e %H:%M:%S") --CUT HERE--"; \
+    zgrep -h "cookie" /var/log/messages*)|sort +0M| \
+    sed '1,/CUT HERE/d'
+# This version fixes those problems.  It adds the file year to the date
+# and puts a marker at the start of the list.
+(echo "$(date -j -f "%s" 0 "+%Y %b %e %H:%M:%S") --ALWAYS FIRST--"; \
+    echo "$(date -v-24H "+%Y %b %e %H:%M:%S") --CUT HERE--"; \
+    for i in /var/log/messages*; do
+       year=$(ls -lT ${i}|awk '{print $9}')
+       zgrep -h "cookie" ${i}|while read line; do
+           echo "${year} ${line}"
+       done
+    done)|sort +0n +1M| sed '1,/CUT HERE/d'
+
+# process a list of quoted values
+{
+    # It tends to be easiest to use a 'here-document' to feed in the list.
+    # I prefer to have the list at the start instead of the end
+    cat <<EOF
+       'general' 'network node0' 'private address'
+       'general' 'options node2' 'kern securelevel'
+EOF
+}| while read line; do
+    eval set -- ${line}
+    config=$1; shift
+    section=$1; shift
+    key=$1; shift
+
+    echo "confutil value \"${config}\" \"${section}\" \"${key}\""
+done
+
+# Method to read lines with a "for" loop, without spawning a subshell
+NEWLINE='
+'
+OIFS="${IFS}"
+IFS="${NEWLINE}"
+for line in $(cat /etc/passwd | sort -r); do
+    IFS="${OIFS}"
+
+    # do whatever you want here
+    echo "line = ${line}"
+
+    IFS="${NEWLINE}"
+done
+IFS="${OIFS}"
+
+# generate a histogram of characters in a file
+cat file|
+    awk '{for (i=1; i <= length($0); i++) {printf("%s\n",substr($0,i,1))}}'|
+    sort|uniq -c
+
+# show line lengths for a file
+cat file| awk '{print length($0)}'| sort -n
+
+
+
+
+# get the modification time of a directory or file and then reset the time.
+target=/usr/local/etc/pkdb
+save_date=$(ls -ldT ${target}|awk '{print $6,$7,$8,$9}')
+save_date=$(date -j -f "%b %e %T %Y" "${save_date}" +"%Y%m%d%H%M.%S")
+# later
+touch -t ${save_date} ${target}
+
+
+# detect NULL bytes in a file
+file=
+hexdump -e '"%_u\n"' ${file}|grep -q '^nul$'
+if [ $? -eq 0 ]; then
+else
+fi
+
+
+# calculate average
+cd /tmp
+uudecode
+begin 644 bc.average
+M<V-A;&4],PIT;W1A;#TP"F-O=6YT/3`*=VAI;&4@*#$I('L*("`@(&YU;2`]
+M(')E860H*0H@("`@:68@*&YU;2`]/2`P*2!B<F5A:SL*("`@(&-O=6YT*RL*
+M("`@('1O=&%L("L](&YU;0I]"B)T;W1A;"`]("([('1O=&%L"B)C;W5N="`]
+K("([(&-O=6YT"B)A=F5R86=E(#T@(CL@=&]T86P@+R!C;W5N=`IQ=6ET"@``
+`
+end
+(cat data; echo "0") |bc -q bc.average
+
+
diff --git a/scripts/examples/bashisms/script_location.sh b/scripts/examples/bashisms/script_location.sh
new file mode 100644 (file)
index 0000000..bdae0fc
--- /dev/null
@@ -0,0 +1,7 @@
+
+# find out the location where this script is running from.  this will not
+# work properly in a bash script that is included via 'source' or '.'.
+# the first letter of each command is escaped to eliminate the danger of
+# personal aliases or functions disrupting the results.
+ORIGINATING_FOLDER="$( \cd "$(\dirname "$0")" && \pwd )"
+
diff --git a/scripts/examples/bashrc_grover b/scripts/examples/bashrc_grover
deleted file mode 100644 (file)
index ddc8662..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-export LC_ALL=C
-alias mc='mc -a'
-
-export PATH=$PATH:/home/QtPalmtop/j2me:/home/QtPalmtop/j2me/bin
-
-alias fredme='export HOME=/home/zaurus/fred ; export TMP=$HOME/.tmp ; source $HOME/yeti/scripts/core/profile.sh ; cd '
-
-
diff --git a/scripts/examples/bashrc_root b/scripts/examples/bashrc_root
deleted file mode 100644 (file)
index 7aaafb9..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# added to root's ~/.bashrc, the yetime macro enables all the yeti tools.
-
-alias yetime='source $HOME/yeti/scripts/core/profile.sh'
-
diff --git a/scripts/examples/bashrc_user b/scripts/examples/bashrc_user
deleted file mode 100644 (file)
index 3e5f4a9..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-
-# in addition to the .bashrc code that the operating system gives you,
-# you can add this file to your ~/.bashrc if you want the YETI scripts
-# to be loaded up automatically.
-#
-# this is for normal users, not the root user!
-
-# note: it is useful to set your own NAME variable to identify who you are.
-# the yeti scripts will set up a bogus one for you otherwise.  in your home
-# directory's .bashrc, you could add something like this, for example:
-#   export NAME='Doodmodeus Q. Nornberton'
-
-# don't bother running our stuff for a dumb terminal since any echo
-# can mess with an sftp connection, apparently.
-if [ ${TERM} != "dumb" ]; then
-  # make sure yeti code hasn't been explicitly disabled.
-  if [ -z "$NO_YETI" ]; then
-    # sets up the yeti scripts, using the default locations for all scripts.
-    source $HOME/yeti/scripts/core/profile.sh
-  fi
-fi
-
diff --git a/scripts/examples/bashrc_user_windoz b/scripts/examples/bashrc_user_windoz
deleted file mode 100644 (file)
index df6df72..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-
-# in addition to the .bashrc code that the operating system gives you,
-# you should added this file to your ~/.bashrc if you want the YETI scripts
-# to be loaded up.
-#
-# you also must run bootstrap_shells.sh if you've never used YETI before.
-
-# note: it is useful to set your own NAME variable to identify who you are.
-# the yeti scripts will set up a bogus one for you otherwise.  in your home
-# directory's .bashrc, you could add something like this, for example:
-#export NAME='Curmudgeon J. Wankslausteen'
-
-export TMP=/h/tmp
-
-# add in some useful paths for the local machine.
-export PATH=/bin:$PATH:/c/utilities/emacs-23.2/bin:/c/tools/cvsnt:/c/utilities/Vim/vim71:/c/system/Perl/site/bin:/c/system/Perl/bin:/c/tools/doxygen/bin:/c/tools/graphviz/Graphviz/bin
-
-export REPOSITORY_DIR="$HOME/hoople2"
-
-if [ -z "$NO_YETI" ]; then
-  # sets up the yeti scripts, using the default locations for all scripts.
-  source $HOME/yeti/scripts/core/profile.sh
-fi
-
-
diff --git a/scripts/examples/custom_overrides/fred/c_common_aliases.txt b/scripts/examples/custom_overrides/fred/c_common_aliases.txt
new file mode 100644 (file)
index 0000000..ec8c5fa
--- /dev/null
@@ -0,0 +1,8 @@
+
+moo='check_mount /z/stuffing ; check_mount /z/walrus ; check_mount /z/chunky '
+unmoo='umount /z/stuffing ; umount /z/walrus ; umount /z/chunky '
+
+refred='(chowngrp -R fred /home/fred /usr/local/games /home/archives /fatty /clutterato /var/spool/mail/fred ; normal_perm /var/log )'
+
+
+
diff --git a/scripts/examples/custom_overrides/fred/c_variables.sh b/scripts/examples/custom_overrides/fred/c_variables.sh
new file mode 100644 (file)
index 0000000..022f1cb
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+# these are my personal overrides.  --fred.
+
+# The quartz directory has *really* personalized items.
+export QUARTZDIR=$HOME/quartz
+
+# The gruntose web site is expected to reside below, if it exists at all.
+export WEB_DIR=$HOME/web
+if [ "$(hostname)" = "zooty.koeritz.com" ]; then
+  export WEB_DIR=/var/www
+fi
+
+# point to our local certificate for ssh usage.
+export SVN_SSH="ssh -i $HOME/.ssh/id_dsa_sourceforge"
+
+# Error and success noises for CLAM.
+export CLAM_ERROR_SOUND='/z/walrus/media/sounds/effects/bwaaang.wav /z/walrus/media/sounds/cartoons/doh4.wav'
+export CLAM_FINISH_SOUND='/z/walrus/media/sounds/cartoons/meepmeep.wav'
+
+# Setup for nethack adventure.
+export NETHACKOPTIONS='name:Manjusri-W,dogname:Fred,catname:Zonker'
+
+# mail setup for home machines.
+export REPLYTO=fred@gruntose.com
+export from="Fred T. Hamster <fred@gruntose.com>"
+
+# set our browser for seti and others that use the variable.
+export BROWSER=/usr/bin/firefox
+
+# editor and other mixed settings...
+export VISUAL=$(which vim)
+
+#hmmm: move these to the uva profile,
+#      rename uva profile to java profile,
+#      get them doing the right thing per OS.
+#  export JAVA_HOME="c:/Program Files/java/jdk1.6.0_11"
+
+# special settings for win32 and svn.
+if [ "$OS" == "Windows_NT" ]; then
+  export EDITOR=$(which gvim)
+fi
+
+# this hideous mess is necessitated by our not having found the source of the
+# settings yet.  we override a few colors that look bad on a dark background.
+export LS_COLORS='no=00:fi=00:di=01;37:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;35:*.rpm=00;33:*.deb=00;33:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;35:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;35:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:'
+
+# we set this to avoid paying for slow app signing on win32.
+export NO_SIGNING=true
+
diff --git a/scripts/examples/custom_overrides/fred/java_profile.sh b/scripts/examples/custom_overrides/fred/java_profile.sh
new file mode 100644 (file)
index 0000000..7186b44
--- /dev/null
@@ -0,0 +1,100 @@
+#!/bin/bash
+# this script tries to intuit where java is installed on this machine.
+
+############################
+
+function intuition_failure()
+{
+  missing="$1"; shift
+  echo "We cannot intuit your $missing variable for this host."
+  # remove the variable because its value is busted.
+  unset $missing
+}
+
+############################
+
+# set some fairly liberal limits for ant.
+export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m"
+
+############################
+
+# start guessing some settings...
+
+# this bin portion works for most javas...
+export JAVA_BIN_PIECE=bin
+
+if [ ! -d "$JAVA_HOME" ]; then
+  # first try a recent linux version.
+  export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
+fi
+if [ ! -d "$JAVA_HOME" ]; then
+  # try using a windows version.
+#note: this logic is untested.
+# probably will break due to space in path issues.
+  declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jdk" 2>/dev/null)
+  if [ ${#any_there[*]} -gt 0 ]; then
+    (( last = ${#any_there[@]} - 1 ))
+    JAVA_HOME="${any_there[$last]}"
+  fi
+  if [ ! -d "$JAVA_HOME" ]; then
+    # if no jdk, try a jre.
+    declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jre" 2>/dev/null)
+    if [ ${#any_there[*]} -gt 0 ]; then
+      (( last = ${#any_there[@]} - 1 ))
+      JAVA_HOME="${any_there[$last]}"
+    fi
+  fi
+fi
+# this should go last, since it changes the bin dir.
+if [ ! -d "$JAVA_HOME" ]; then
+  # if that didn't work, try the location for mac os x.
+  JAVA_HOME=/Library/Java/Home
+  JAVA_BIN_PIECE=Commands
+fi
+# last thing is to tell them we couldn't find it.
+if [ ! -d "$JAVA_HOME" ]; then
+  intuition_failure JAVA_HOME
+  unset JAVA_BIN_PIECE
+fi
+
+############################
+
+# intuit where we have our local eclipse.
+if [ ! -d "$ECLIPSE_DIR" ]; then
+  export ECLIPSE_DIR=/usr/local/eclipse_jee
+fi
+if [ ! -d "$ECLIPSE_DIR" ]; then
+  ECLIPSE_DIR=$HOME/eclipse
+fi
+if [ ! -d "$ECLIPSE_DIR" ]; then
+  ECLIPSE_DIR=$HOME/apps/eclipse
+fi
+if [ ! -d "$ECLIPSE_DIR" ]; then
+#uhhh, default on winders?
+  ECLIPSE_DIR="/c/Program Files/eclipse"
+fi
+if [ ! -d "$ECLIPSE_DIR" ]; then
+  ECLIPSE_DIR="/c/tools/eclipse"
+fi
+if [ ! -d "$ECLIPSE_DIR" ]; then
+  ECLIPSE_DIR="/d/tools/eclipse"
+fi
+if [ ! -d "$ECLIPSE_DIR" ]; then
+  ECLIPSE_DIR="/e/tools/eclipse"
+fi
+# final option is to whine.
+if [ ! -d "$ECLIPSE_DIR" ]; then intuition_failure ECLIPSE_DIR; fi
+
+############################
+
+# use the variables we just set in our path, and try to make them override
+# any other paths to different versions.
+
+if [ ! -z "$JAVA_HOME" ]; then
+  export PATH=$JAVA_HOME/$JAVA_BIN_PIECE:$PATH
+fi
+if [ ! -z "$ECLIPSE_DIR" ]; then
+  export PATH=$ECLIPSE_DIR:$PATH
+fi
+
+
diff --git a/scripts/examples/custom_overrides/readme.txt b/scripts/examples/custom_overrides/readme.txt
new file mode 100644 (file)
index 0000000..d7ab4c6
--- /dev/null
@@ -0,0 +1,15 @@
+
+
+this folder has some examples of how various people (or one person right now)
+do their custom scripts.
+
+the scripts often have the same name as the main script's name, but with
+a "c_" in front.  ones understood currently are:
+  c_common_aliases.txt
+  c_sh_aliases.txt
+  c_variables.sh
+
+when you have some custom scripts you want to use, copy them from your own
+folder to the scripts/custom directory.  be careful though, because they
+will never be checked into the repository from there.
+
diff --git a/scripts/examples/example_registry_ops.sh b/scripts/examples/example_registry_ops.sh
deleted file mode 100644 (file)
index 3480d94..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-# an example of using the reg.exe tool on windows to find some things in
-# the registry.
-# this happens to look in the registry for PuTTY keys for a set of named
-# displays.
-
-declare ip_array=(zorba-1 zorba-2 zorba-3 zorba-4 zorba-5)
-
-for i in ${ip_array[*]}; do 
-  target=${i}
-  echo "display is $target"
-  reg query 'HKCU\Software\SimonTatham\PuTTY\SshHostKeys' /v "rsa2@22:$target"
-done
-
-
diff --git a/scripts/examples/feisty_meow_startup/bashrc_grover b/scripts/examples/feisty_meow_startup/bashrc_grover
new file mode 100644 (file)
index 0000000..ddc8662
--- /dev/null
@@ -0,0 +1,8 @@
+export LC_ALL=C
+alias mc='mc -a'
+
+export PATH=$PATH:/home/QtPalmtop/j2me:/home/QtPalmtop/j2me/bin
+
+alias fredme='export HOME=/home/zaurus/fred ; export TMP=$HOME/.tmp ; source $HOME/yeti/scripts/core/profile.sh ; cd '
+
+
diff --git a/scripts/examples/feisty_meow_startup/bashrc_root b/scripts/examples/feisty_meow_startup/bashrc_root
new file mode 100644 (file)
index 0000000..7aaafb9
--- /dev/null
@@ -0,0 +1,4 @@
+# added to root's ~/.bashrc, the yetime macro enables all the yeti tools.
+
+alias yetime='source $HOME/yeti/scripts/core/profile.sh'
+
diff --git a/scripts/examples/feisty_meow_startup/bashrc_user b/scripts/examples/feisty_meow_startup/bashrc_user
new file mode 100644 (file)
index 0000000..3e5f4a9
--- /dev/null
@@ -0,0 +1,22 @@
+
+# in addition to the .bashrc code that the operating system gives you,
+# you can add this file to your ~/.bashrc if you want the YETI scripts
+# to be loaded up automatically.
+#
+# this is for normal users, not the root user!
+
+# note: it is useful to set your own NAME variable to identify who you are.
+# the yeti scripts will set up a bogus one for you otherwise.  in your home
+# directory's .bashrc, you could add something like this, for example:
+#   export NAME='Doodmodeus Q. Nornberton'
+
+# don't bother running our stuff for a dumb terminal since any echo
+# can mess with an sftp connection, apparently.
+if [ ${TERM} != "dumb" ]; then
+  # make sure yeti code hasn't been explicitly disabled.
+  if [ -z "$NO_YETI" ]; then
+    # sets up the yeti scripts, using the default locations for all scripts.
+    source $HOME/yeti/scripts/core/profile.sh
+  fi
+fi
+
diff --git a/scripts/examples/feisty_meow_startup/bashrc_user_windoz b/scripts/examples/feisty_meow_startup/bashrc_user_windoz
new file mode 100644 (file)
index 0000000..df6df72
--- /dev/null
@@ -0,0 +1,25 @@
+
+# in addition to the .bashrc code that the operating system gives you,
+# you should added this file to your ~/.bashrc if you want the YETI scripts
+# to be loaded up.
+#
+# you also must run bootstrap_shells.sh if you've never used YETI before.
+
+# note: it is useful to set your own NAME variable to identify who you are.
+# the yeti scripts will set up a bogus one for you otherwise.  in your home
+# directory's .bashrc, you could add something like this, for example:
+#export NAME='Curmudgeon J. Wankslausteen'
+
+export TMP=/h/tmp
+
+# add in some useful paths for the local machine.
+export PATH=/bin:$PATH:/c/utilities/emacs-23.2/bin:/c/tools/cvsnt:/c/utilities/Vim/vim71:/c/system/Perl/site/bin:/c/system/Perl/bin:/c/tools/doxygen/bin:/c/tools/graphviz/Graphviz/bin
+
+export REPOSITORY_DIR="$HOME/hoople2"
+
+if [ -z "$NO_YETI" ]; then
+  # sets up the yeti scripts, using the default locations for all scripts.
+  source $HOME/yeti/scripts/core/profile.sh
+fi
+
+
diff --git a/scripts/examples/os_related/example_registry_ops.sh b/scripts/examples/os_related/example_registry_ops.sh
new file mode 100644 (file)
index 0000000..3480d94
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+# an example of using the reg.exe tool on windows to find some things in
+# the registry.
+# this happens to look in the registry for PuTTY keys for a set of named
+# displays.
+
+declare ip_array=(zorba-1 zorba-2 zorba-3 zorba-4 zorba-5)
+
+for i in ${ip_array[*]}; do 
+  target=${i}
+  echo "display is $target"
+  reg query 'HKCU\Software\SimonTatham\PuTTY\SshHostKeys' /v "rsa2@22:$target"
+done
+
+
diff --git a/scripts/examples/script_location.sh b/scripts/examples/script_location.sh
deleted file mode 100644 (file)
index bdae0fc..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-
-# find out the location where this script is running from.  this will not
-# work properly in a bash script that is included via 'source' or '.'.
-# the first letter of each command is escaped to eliminate the danger of
-# personal aliases or functions disrupting the results.
-ORIGINATING_FOLDER="$( \cd "$(\dirname "$0")" && \pwd )"
-