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

bashrc files
uqjau scripts
cygwin setup

site uses:

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

  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.

  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:
  - run by bash as in

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

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

  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.

  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.

  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.

  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.

  save sector zero of all disks; monitor chgs

  filter typically driven by 'find'.  Prints "'ls -l' like" output on each
  file and prepends a sortable (base 36) seconds (mtime) timestamp. 
  calls tsid function which converts current time in
  seconds as lower case 6 char base 36 string

  $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!

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

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

  compare two java ear files

  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. 

  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.

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

  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.

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

  echo Internet FQDN for current host, per DNS PTR lookup

  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.

  If file changed check into RCS archive and return 1.

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

  soak up all standard input; and only then, write that input

fileutils-misc.shinc: _dir_filecounts()
  Report combined file/dir count in each dir 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. 
  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". 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

  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.

  Time billing, time and task tracking.

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

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

  $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.

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

  rsync $ref_user@$ref_host:$ref_dir to CWD

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

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

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

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

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

  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

  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".

  Filter to remove duplicate paragraphs.

  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.

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

  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. 
  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

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