Skip to main content

Posts

Showing posts from 2008

HTML Grapher in Bash- A bash (awk et al) script for graphing two columns to HTML/CSS

#!/bin/sh # # * Copyright (c) 2008 # * Adam Keck. All rights reserved. # * # * Redistribution and use in source and binary forms, with or without # * modification, are permitted provided that the following conditions # * are met: # * 1. Redistributions of source code must retain the above copyright # * notice, this list of conditions and the following disclaimer. # * 2. Redistributions in binary form must reproduce the above copyright # * notice, this list of conditions and the following disclaimer in the # * documentation and/or other materials provided with the distribution. # * 3. The name Adam Keck may not be used to endorse or promote products derived from this software # * without specific prior written permission. # * # * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND # * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # * ARE DIS

Systems Administration Koans [2008]

Some koans... ----------- A sysadmin asked the Master, "What's the best way to install a new system?" The Master answered, "Turn it on." The sysadmin was enlightened. ----------- A sysadmin asked the Master, "What's the root password to this server?" The Master asked, "Do you have access to the console?" The sysadmin replied, "Yes." The Master replied, "The root password is whatever you want it to be." The sysadmin was enlightened. ----------- An sysadmin seeks approval from the Master: "Master, I have designed and implemented a system with no single points of failure!" The Master answered, "Have you documented it?" "Not yet - I wanted to get it done first." The Master asked, "Give me the name of a team member that can build another one without seeing you or contacting you." "Well, I can't, yet - I just built it." The

Days Between

A little script to tell you the days between two YYYYMMDD dates: #!/bin/bash function usage { echo "date {date} {date}, where date is in the format YYYYMMDD" } function absolute_value { echo $1 | sed s/-// } # Print help, if number of args wrong if [ -z $2 ] then usage 1>&2 exit 1 fi if [ $3 ] then usage 1>&2 exit 1 fi # The dates we want to days between DATE_ONE="$1" DATE_TWO="$2" # provide the original date instead of "now" and ask for "seconds since epoch" DATE_ONE_EPOCH=$(date -d "${DATE_ONE}" "+%s") DATE_TWO_EPOCH=$(date -d "${DATE_TWO}" "+%s") #Math DAYS=$(($((${DATE_ONE_EPOCH} - ${DATE_TWO_EPOCH}))/$((60*60*24)))) absolute_value $DAYS ------ Note the unmath in "absolute_value" ;-)

Linux Live Search...

So... The other day I decided to set up 'locate' to find files in my home network shares, /home/ghostis and /sandbox/ghostis. To do so, I did the following: % mkdir /home/ghostis/Documents/locate Added the an updatedb job to my crontab on my laptop: 15,30 * * * * updatedb --netpaths='/home/ghostis /sandbox/ghostis' --output=/home/ghostis/Documents/locate/locatedb --localpaths=' ' Now I can do faster searches of filenames via: locate -d ~/Documents/locate/locatedb sometextinfilename But, then I thought, "What's the absurd extreme?" Linux Live Search! So I baked a quick bash script: % cat linux_live_search.sh #!/bin/bash clear echo "Please type something. (Escape spaces. Ctrl-C to quit)" echo "------------------------------------------" echo "Query: $WORD" echo "------------------------------------------" while read -s -n1 KEY do clear if [ "$KEY" = "" ] then WORD=`echo "$WOR