BreadCrumbs: Bash Scripts

Bash Scripts

From Luke Jackson

Revision as of 15:48, 5 December 2007; Ljackson (Talk | contribs)
(diff) ←Older revision | Current revision | Newer revision→ (diff)
Jump to: navigation, search

Simple Wget Loop

alpha=( aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu vv ww xx yy zz )

alpha_count=${#alpha[*]}

x=0

while [ "$x" -lt "$alpha_count" ]
do    # List all the elements in the array.
  wget -O ${alpha[$x]}.wav http://german.about.com/library/media/sound/${alpha[$x]}.wav
  sleep 1
  let "x = $x + 1"
done

Conditional Device Check & Image Upload (Mac OS X)

#!/bin/bash

CAMSTAT=`/usr/sbin/system_profiler SPUSBDataType | awk '{$1=$1;print}' | grep WebCam | cut -c 1-6`

if [ "$CAMSTAT" = "WebCam" ]; then

 # Create History Image
 echo Make History
 scp -P 2222 ~/m31uk3.jpg me@server.com:/www/server.com/htdocs/webcam/history/m31uk3_`date +%s`.jpg

 # Update Webcam
 echo Take a Picture
 scp -P 2222 ~/m31uk3.jpg me@server.com:/www/server.com/htdocs/webcam/

else
 echo No Cam Connected!
fi


Move Files Based On Date Name

for ARG in $*
do
  PICPATH=`echo $ARG | cut -d_ -f 2 | cut -d. -f 1 | utimecam`
#  echo $PICPATH
  mv -v $ARG $PICPATH/$ARG
#  sleep 1
done
Personal tools