Perhaps change the `cut -d \" \" -f 2` to `awk '{print $2}'`? If the outpout contains tabs instead of spaces the `cut` command will take it as 4 fields instead of only one.