jots on linux/UNIX system administration, bash and perl -Tom Rodman

home
bashrc files
uqjau scripts
cygwin setup

site uses:

== Synopsis of 'higher rated' or 'significant' uqjau scripts. ==

jobmon: 
  Job wrapper: run and log (STDOUT/STDERR/exit code/duration)
  of another script.  Useful for cron jobs. Logs files self-purged.
  The scripts (metaquoted) args may be passed to ourname.

fileutils-misc.shinc: sf()
  sort filesystem pathnames by mtime or size.  Two modes:
  one using find, the other as pathname filter.

rcsbu: 
  Recursively find rcs source and history files in specified
  dirs, tar RCS ",v" files (history archives), and related current
  standalone (non RCS) version; archive these files to a "rotation-named"
  tar.gz file.

argsshow: _argsshow()
  Show commandline arguments, 1 per line. Debugging tool.
  Keep in mind that an arg may be a multiline string.

requote_args_using_xtrace.shinc: requote_args_using_xtrace()
  Use shell xtrace option to meta quote "".
  Our output string may be:
  - written to a script file and later run by invoking the script.
  - run in current shell as in:
  eval OUROUTPUTHERE
  - run by bash as in
  echo OUROUTPUTHERE|bash

sysconf_ls: 
  check in snapshot of host's (Linux) system
  configuration files to RCS archive. Briefly report some basics
  of system configuration. Log all steps.

backupall: 
  tar backup of local filesystems, rewind and read each
  tape file. A log is created.  Remote tape drive supported.

key2agent: 
  Loads private ssh key specified to your ssh agent,
  supplying passphrase taken from encrypted file, starting an ssh
  agent if needed.  Uses keychain which gracefully handles case
  where key already loaded.

filescontents_stable: 
  Monitor a list of file or symbolic link pathnames for
  content changes using md5sum. Return 1, and list the changed
  pathnames if change(s) found.

rc4-2w: 
  Encrypt/decrypt text using RC4. Supports a scheme
  for host password encrypt/decryption.  For usage:
  $ourname --help 

array_from_STDIN_for_eval.shinc: array_from_STDIN_for_eval()
  Build bash array or list from STDIN. You need to
  eval the STDOUT of this function.

misc._m4.shinc: _m42()
  run 'm4 -P' on STDIN, silently run 'm4 -p' first on
  '${@}' file.  By default first filters through cat_or_eval, next
  special changequote used, '$(_29lib)/_29r_sh.m4' code macros
  sourced, and post-m4 quadragraphs run.

simple_command_readtoarg0: 
  read simple command, identifying env assignments
  and command basename. (see 'man bash' for definition of
  "simple command") Invoke w/${0} == simple_command_basename or
  simple_command_env_assignments to get behavior wanted.

sector0_bu: 
  save sector zero of all disks; monitor chgs

ls_tsid_filter: 
  filter typically driven by 'find'.  Prints "'ls -l' like" output on each
  file and prepends a sortable (base 36) seconds (mtime) timestamp.

tsid.pl: 
  calls tsid function which converts current time in
  seconds as lower case 6 char base 36 string

_m4: 
  $ourname runs: 
  m4 -P $initial_macros $_29lib/_chg_comment0.m4 $_29lib/_chg_quote0.m4 ""  # generates SDTOUT
    $ head -1 $_lib/_chg_quote0.m4  
  # run manually to see, but do *not* put literal output in this synopsis!

_m4s: 
  filter, expands macros using: make -rf $_lib/makefile_29r

unzip_ear_recursively: 
  unzip ear files, and the zip, war, or jar archives within

ear_cmp: 
  compare two java ear files

_bg: 
  Run simple command in background in separate
  process session.  Will not be seen by your shell as a job.  Log
  STDOUT and STDERR to file. Simple command => exactly 1 command
  and it's args. 

cat_or_eval: 
  Filter that passes STDIN unchanged, unless a special
  key string seen at start of line - then it runs the shell command
  specified to create STDOUT for that line.

_txt-any: 
  Count text line ending types; binary files OK.
  Useful for troubleshooting mysteries w/unusual files or file formats.

_fget: 
  use wget (or curl [deprecated]) to down load URLs
  listed on STDIN (common use: get mp3 files) Logs failed
  downloads, ^C skips cur file, ^\ quits.

Iip: 
  (experimental) get your host's IP address on network
  that has route to Internet

_IPTR: 
  echo Internet FQDN for current host, per DNS PTR lookup

save2fifo: 
  Make a fifo (currently in a fixed location), which
  creates a new temp file (to a currently fixed subdir ) each time
  a write to this fifo is completed.

deltafilealarm00: 
  If file changed check into RCS archive and return 1.

since: 
  show time delta from now to a specified date, where
  date is specified in any format understood by "GNU date"

_sponge: 
  soak up all standard input; and only then, write that input
  to PATHNAME  or STDOUT

fileutils-misc.shinc: _dir_filecounts()
  Report combined file/dir count in each dir recursively

gunzip_recursively: 
  unzip all *.gz files within either a tar archive or
  a given directory. As the search finds tar files untar when tar archive
  contains at least one *.gz file.

_subst_nested.pl: 
  Filter: runs a subst (substitute) command on a regex
  defined subset of the line.  The subset may appear multiple
  times on the line.

basename.shinc: _dirname()
  dirname written as bash function, but pathname will always
  end in "/".

basename.shinc: _basename()
  basename written as bash function

basename.shinc: _symlink_referent()
  runs 'ls -ld' on symbolic link returning pathname to right
  of "> ".

basename.shinc: _stemdir()
  accepts exactly 1 pathname to a directory, and echo
  that pathname with the leaf directory removed.  The pathname
  echoed ends with "/".

fileutils-misc.shinc: _backfile()
  copy file to a backup w/md5sum added to name, unless
  valid backup made by $ourname exists

fileutils-misc.shinc: _dir_filecounts()
  Report combined file/dir count in each dir recursively

fileutils-misc.shinc: pb()
  paste /append/ to 'pastebin' log file, with dated
  header for each append, many additional options

fileutils-misc.shinc: _md5sum_symlink()
  Use output of readlink SYMLINKPATHNAME, to make
  md5sum for each symbolic link argument.

fileutils-misc.shinc: _pathname_sort_by_basename()
  Filters as name indicates.

_tar_tf_touch: 
  "tar tf" "touch". Untar archive, then empty out all
  files, preserving timestamps.  Positions one to find them
  w/'locate'. "tar tf touch"

_tape_utils.shinc: _tar()
  GNU tar wrapper to support remote tape drive

_tape_utils.shinc: tar_filesystem()
  tar a directory, staying in it's filesystem.  Modify exit
  code, by running tar STDERR output through 'gnutar_ok'.  This function
  'cd's to the directory before starting tar.

_pn (symlink to "path-ab"): 
  print absolute pathname for pathnames

_backup: 
  tar backup of local filesystems to rotated archives

_untar_pkg.shinc: _untar_pkg()
  Untar tarfile to temp dir, and echo pathname. Assumes
  untar creates exactly 1 subdir; usually true for software packages.

_untar_pkg.shinc: _untar_pkg()
  create temp scratch dir and cd to it. Default parent
  is ~/tmp.

bt: 
  Time billing, time and task tracking.

buud: 
  copy a file over top of existing file, but backup the dest
  file first.  The backup file has a "temp file suffix".

_ci: 
  Wrapper for rcs ci/co. Updates ",v file", never touches 
  source file.

ssh-agls: 
  Save ssh SSH_AGENT_PID and SSH_AUTH_SOCK to
  $HOME/.ssh/agent_now_running, so that it may be sourced by new
  shells.  Also saves output of 'ssh-add -ls'.  Useful for systems
  that do not have keychain.

job_log: 
  take (meta-quoted) commandline defined job, run it,
  logging combined STDERR/STDOUT & exit code. Optionally email the log 
  for failed jobs.

update-rsync2-cwd: 
  rsync $ref_user@$ref_host:$ref_dir to CWD

nap2: 
  Given a GNU future-date-string; will sleep 'til then.
  Acceptable args are those honored by 'date --date'.
  Ex
  $ourname now +20 min
  $ourname 10am Monday

net-basics.shinc: get_dotcom_soa()
  DNS lookup SOA for 'com.'  Failure suggests Internet down.

batchmail1: 
  Convert an email msg into, 'at' job, scheduling an
  email to be sent in future.

affirmconsole: 
  Runs in background, periodically sending random
  paragraphs of $FORTUNE_DIR/fortune* to current tty.

remind.console: 
  Single-shot tickler/alarm; echos out reminder
  phrase to current tty at specified time or after specified delay.

paragraph-flatten: 
  Flatten paragraphs by swapping \n with \r, so each paragraph
  is 1 line long.  A paragraph is delimited by one or more empty lines.
  Value: grep matches return entire paragraph.  Also known by symbolic link
  '_parf'.

paragraph-random: 
  Like fortune program. A filter that prints out a
  random paragraph. Each paragraph must be separated with an empty
  line. Code taken/adapted from the March 1992 "camel" perl book -
  "Common Tasks with Perl", "SELECTING A RANDOM LINE FROM A FILE".

_par_ddup: 
  Filter to remove duplicate paragraphs.

wrap-text-lossless: 
  Minimal text wrap filter, based on perl Text::Wrap.
  Wrapped lines prefixed w/"*** ".
  Good for code with long lines; you want to show where you wrapped.

pjsum: 
  Personal work log filter, for time tracking work tasks.
  Keywords: Time billing, time accounting, time card, project plan.

_txt: 
  count lines ending with \n, and \r\n separately; ie
  total DOS text lines, and UNIX text lines separately.  If any
  \r is not at end of line, display those lines and exit w/code 2.

updatedb.win.batch: 
  Windows specific wrapper for 'updatedb-rootdirs-w-spaces'.

_untar_URL.shinc: _untar_URL()
  wget tarfile and untar to temp dir, echo pathname to
  toplevel subdir in untarred temp dir.

bash_common.shinc: _SIGERR_handler()
  SIGERR trap code. Logs debug info before script exit.
  Skips cleanup.

bash_common.shinc: _pre_death_errlog()
  Is called by _SIGERR_handler

bash_common.shinc: _explain_errexit_concept()
  Give help/explain bash errexit flag (set -e).

bash_common.shinc: exit()
  Overload the builtin "exit" (to support the EXIT trap and
  _handle_EXIT_sig function). "exit" resolves to builtin "exit 0".

bash_common.shinc: _our_cleanup()
  Cleans up '_we_are_running' flag file, other temp files,
  calls _cleanup function if you defined it.

bash_common.shinc: _handle_EXIT_sig()
  Script did *not* call our overloaded 'exit' function as it
  should have done had all went OK, and script had ended as we
  recommend, w/an 'exit' statement.

bash_common.shinc: _set_fatal_traps()
  trap signals meant to end script
  see also _handle_fatal_sig

bash_common.shinc: _snapshot_self()
  used to write to basic info about this script to file $_we_are_running

mpp: 
  Starts a commandline/readline "shell" to control winamp
  through winamp's clamp.exe (winapp mp3 player). (cygwin only)