converted bash scripts to ruby