Hi, it's unclear how you want the script to know what system command to use - should that be hardcoded in the script? Also unclear how the select should work - sort, order, range...? What about error conditions, during the connection to the DB, in the select or while running the system command?
Assuming you specify these things in more detail, I'd be glad to help. Thank you.