so i started taking pictures and realized that when i dumped all the pics off my cf card that it would just dump all the pics into one folder. so using exif (in gentoo “emerge media-gfx/exif”, from source: http://libexif.sourceforge.net/) i came up with a quick snippet using exif to move the pictures to the proper … Read More
so i decided to have my wallpaper in evilwm switch up every 60 seconds but since setting the wallpaper in evilwm requires the usage of feh, xv or some other utility i came up with this little script below which gets daemonized by .xinitrc at login: #!/bin/bash while :;do files=(/path/to/*.jpg /path/to/*.jpeg /path/to/*.png /path/to/*.gif) N=${#files[@]} ((N=RANDOM%N)) … Read More
here is a quick and dirty little script to see how many open files tomcat is using up. #!/bin/bash USER=tomcat LSOF=`lsof -u $USER | wc -l` OPEN_F=`ulimit -a | egrep “open files” | awk ‘{print $4}’` #PERCDONE=$(( $LSOF / $OPENF * 100 )) PERCDONE_PRE=$(echo “scale=2;(($LSOF/$OPEN_F) * 100)” |bc) PERCDONE=`echo $PERCDONE_PRE | cut -d. -f1` if … Read More
DIRP=”location of backups” DATE=$(date +”%m-%d-%y”) MYSQL_SERVER=”location of mysql server” USER=”mysql user” PASSWORD=”mysql password LOOP_VAR=”mysql db names without prefix” for LOOP_VAR_TXT in $LOOP_VAR do LOOP_VAR_FILE=${DIRP}/${LOOP_VAR_TXT}.${DATE}.sql LOOP_VAR_DB=”db prefix”_$LOOP_VAR_TXT /usr/bin/mysqldump –user=$USER –password=$PASSWORD –host=$MYSQL_SERVER $LOOP_VAR_DB > $LOOP_VAR_FILE /usr/bin/tar -czvf ${LOOP_VAR_FILE}.tgz $LOOP_VAR_FILE rm $LOOP_VAR_FILE done find ${DIRP}mysql -mtime +13 -exec rm -f {} \; some quick and dirty code i … Read More
quick and dirty script to rename *.jpg in one folder to poa_xxx.jpg numerically yes there is a way to do this in a shorter and cleaner matter. but i was tired and just wanted to get it done. #/bin/bash n=1 for f in *.jpg do if [ $n -le 9 ]; then mv “$f” “poa_000$n.jpg” … Read More
i was in a crunch. so i put together this little hack script to run every night to ensure that user quotas were being set for all users: #!/bin/bash NAMES=`ls -l <change this to user home> | awk ‘!/total/ {print $3}’` for NAMES in $NAMES; do edquota -p <change this to protoname> $NAMES done
begin snippet: function port { if [ $? -ne 0 ] ; then printf “warning: ” if [ $? -eq 6 ]; then echo “cant resolve host” fi if [ $? -eq 7 ]; then echo “cant connect to host” fi printf “site may be down\n” else printf “site is up\n” fi } curl -s … Read More
this script looks in a specific directory for sql dumps labeled xxx_20080101_xxx_alumn.sql.gz, xxx_20080101_xxx_const.sql.gz & xxx_20080101_xxx_log.sql.gz to ungzip and dump back into sql (assuming the db is there already). change as needed. #!/bin/bash # this script assumes that you have the sql backups gzipped FILE_DIR=/export/tmp/backup/temp if [ $# -lt 2 ]; then printf “\nneeds date of … Read More
boredom led me to write a command that does the same thing but three different ways; assume that the file that is being cat to use for this example contains: line 1 line 2 <form id=”form_login” name=”form_login” method=”post” action=”session_id=XXXXXx.xxxxx.NAM1&locid=0&lf=0&i> and i need NAM1 only. well, i actually need the three letter code and number. it … Read More
here is another in the long line of stupid scripts for nagios. this script finds specific process, then counts them and spits out an error level according to setting enjoy!! #!/bin/bash ## replace “ORA_” with some other unique identifier ## from vi :1,$s/ORA_/”unique”/g ORA_TEMP=/tmp/ora_procs.tmp ## replace “ora_” with what you need grep’ed ps -ef | … Read More