Why not have a file where you have list of ip's and read the file and execute the command.