in reply to Automate an SQL tool

If that executable is something like mysql or a client of any other well-known database, you'll be better off using Perl's DBI module and its DBD::mysql, DBD::Pg, DBD::SQLite, etc. companions, talking to your database directly.