Turns out I'm pretty bad with bash. Missing a couple of $ in front of variables. Fixed.