BreadCrumbs: Bash Scripts

Bash Scripts

From Luke Jackson

(Difference between revisions)
Jump to: navigation, search
Revision as of 23:16, 28 June 2007 (edit)
Ljackson (Talk | contribs)
(Simple Wget Loop)
← Previous diff
Revision as of 21:55, 11 September 2007 (edit)
Ljackson (Talk | contribs)

Next diff →
Line 1: Line 1:
-=== Simple Wget Loop ===+== Simple Wget Loop ==
<pre> <pre>
Line 15: Line 15:
done done
</pre> </pre>
 +
 +== Conditional Device Check & Image Upload ==
 +
 +<pre>
 +#!/bin/bash
 +
 +CAMSTAT=`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 root@thatshawt.com:/www/thatshawt.com/htdocs/webcam/history/m31uk3_`date +%s`.jpg
 +
 + # Update Webcam
 + echo Take a Picture
 + scp -P 2222 ~/m31uk3.jpg root@thatshawt.com:/www/thatshawt.com/htdocs/webcam/
 +
 +else
 + echo No Cam Connected!
 +fi
 +</pre>
 +
[[Category:Linux]] [[Category:Linux]]
[[Category:Mac OS X]] [[Category:Mac OS X]]

Revision as of 21:55, 11 September 2007

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

#!/bin/bash

CAMSTAT=`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 root@thatshawt.com:/www/thatshawt.com/htdocs/webcam/history/m31uk3_`date +%s`.jpg

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

else
 echo No Cam Connected!
fi
Personal tools