I have a script I've setup to run a number of tasks, one of which is to set up a table in a DB and later remove it (for automated testing).The issue comes that on only a few of the users that I use the su - user -c command, the call to db2 fails. The odd thing however, is that using su - user and then running the db2 command works fine (outside of the script). This only happens after I have run the script once and during the script running process (though there's nothing I can see that would cause it to somehow change anything, sadly I can't share the exact code, though I could share an example/recreation of it if it would help), which merely contains a few basic loops, and a bunch of su - user -c commands calling IBM mq commands.For example this fails:su - user -c db2 connect to database USER user USING pass; db2 'CREATE TABLE LETABLE (LEFIELD VARCHAR (16))'Error:DB21016E The Command Line Processor encountered a system error while sending the command to the backend process.DB21018E A system error occurred. The command line processor could not continue processing.However this works fine:su - userdb2 connect to database USER user USING passdb2 'CREATE TABLE LETABLE (LEFIELD VARCHAR (16))'I've tried outputting the env command in both cases, to see if there's somehow something different, but they match as would be expected. I've also tried adjusting the order the different users run in, but that doesn't seem to help either.I am truly confused and any help would be greatly appreciated.I am using a ksh shell.
su -c command fails when sending db2 commands
ksh;su;db2
I have a workaround that seems to work.I created a separate ksh script that does all the db2 commands (establish a connection, then creates a table and grants permissions on it), and run that with any arguments needed.This means that it's running a set of commands in one su instance, despite using the -c part, so as to run it inside the script effectively.