Well with kshell I'm fairly certain you're limited to executing everything via a secondary command line app (such as the mysql command, or sqlplus). So you'd be stuck just sending everything via command line like this:
mysql -u user -ppassword commands....
Unfortunately, I know nothing about posix.
That's what I used to do, using SQL*Plus commands within a Korn shell to connect to an Oracle DB. Been quite a few years since I did that, though.
In any case, note that Perl (or PHP for that matter, too) scripts can be run as command line scripts, allowing you to use available/built-in DB libraries; and most *nix hosts these days have both installed.