Advertisement
Guest User

pleasedontfindthis

a guest
Aug 28th, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.66 KB | None | 0 0
  1. #!/bin/bash
  2. dateid=$1
  3. basecommand="/home/ubuntu/www/rmi/bin/rails runner "
  4.  
  5. #Start of loop
  6. while read line ; do
  7.  
  8.         #execue ruby get and push the result into a var
  9.         result="$(ruby get_mp_content.rb $dateid $line)"
  10.  
  11.         #remove brackets, since they usually fuck stuff up.
  12.         result=$(echo $result | sed -e 's/(/ /g' -e 's/)/ /g')
  13.  
  14.         #Extract the currency values, aswell as proceeding characters
  15.         uglymoney=$(grep -o '.\{0,7\}£.\{0,7\}' <<< "${result}")
  16.         echo "uglymoney:"
  17.         echo $uglymoney
  18.  
  19.         dropdecimal=$(sed -e 's/\.[0-9][0-9]/ /g' -e 's/\.[0-9]/ /g' <<< "$uglymoney")
  20.         echo "dropdecimal"
  21.         echo $dropdecimal
  22.  
  23.         #Process the uglymoney var by removing non int characters, then total the result
  24.         totaltaken=$(perl -pe 's/\s+/\n/g' <<< "$dropdecimal" | sed -e 's/[^0-9]*//g' -e '/^$/d' -e 's/£//'   | xargs  | sed -e 's/\ /+/g' | bc)
  25.         #totaltaken=$(perl -pe 's/\s+/\n/g' <<< "$uglymoney" | sed -e 's/[^0-9]*//g' -e '/^$/d' -e 's/£//'   | xargs  | sed -e 's/\ /+/g' | bc)
  26.  
  27.         #Format the name of the Member into Firstname Lastname with correct capitalisation
  28.         prettyname=$(sed -e  's/_/ /' -e 's/.htm//' -e 's/\b\(.\)/\u\1/g'  <<< "$line" | awk '{print $2 " " $1}')
  29.  
  30.         #Build the argument string which will be injected into rails runner.
  31.         args="'f = Member.create :name => \"$prettyname\", :date => \"$dateid\", :content => \"$result\", :total => \"$totaltaken\"'"
  32.  
  33.         #Build the full command, including the rails runner absolute path
  34.         fullcommand=$basecommand$args
  35.  
  36. echo "Processing: "$prettyname
  37. eval $fullcommand
  38.  done< mpendpoints$1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement