Boy gets trousers stuck on top of automated gates