Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- dateid=$1
- basecommand="/home/ubuntu/www/rmi/bin/rails runner "
- #Start of loop
- while read line ; do
- #execue ruby get and push the result into a var
- result="$(ruby get_mp_content.rb $dateid $line)"
- #remove brackets, since they usually fuck stuff up.
- result=$(echo $result | sed -e 's/(/ /g' -e 's/)/ /g')
- #Extract the currency values, aswell as proceeding characters
- uglymoney=$(grep -o '.\{0,7\}£.\{0,7\}' <<< "${result}")
- echo "uglymoney:"
- echo $uglymoney
- dropdecimal=$(sed -e 's/\.[0-9][0-9]/ /g' -e 's/\.[0-9]/ /g' <<< "$uglymoney")
- echo "dropdecimal"
- echo $dropdecimal
- #Process the uglymoney var by removing non int characters, then total the result
- totaltaken=$(perl -pe 's/\s+/\n/g' <<< "$dropdecimal" | sed -e 's/[^0-9]*//g' -e '/^$/d' -e 's/£//' | xargs | sed -e 's/\ /+/g' | bc)
- #totaltaken=$(perl -pe 's/\s+/\n/g' <<< "$uglymoney" | sed -e 's/[^0-9]*//g' -e '/^$/d' -e 's/£//' | xargs | sed -e 's/\ /+/g' | bc)
- #Format the name of the Member into Firstname Lastname with correct capitalisation
- prettyname=$(sed -e 's/_/ /' -e 's/.htm//' -e 's/\b\(.\)/\u\1/g' <<< "$line" | awk '{print $2 " " $1}')
- #Build the argument string which will be injected into rails runner.
- args="'f = Member.create :name => \"$prettyname\", :date => \"$dateid\", :content => \"$result\", :total => \"$totaltaken\"'"
- #Build the full command, including the rails runner absolute path
- fullcommand=$basecommand$args
- echo "Processing: "$prettyname
- eval $fullcommand
- done< mpendpoints$1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement