1

When I type this:

su <user> -c "/home/<user>/sqllib/bin/db2 catalog tcpip node <dbName> remote <ip> server <port>"

I get this error message:

SQL10007N Message "-1390" could not be retrieved.  Reason code: "3".

But when I do this:

su <user>
/home/<user>/sqllib/bin/db2 catalog tcpip node <dbName> remote <ip> server <port>

It works fine.

The problem is, I can't use "su" without -c because I'm placing this into a Python script, and Python loses the prompt to Bash when it runs "su".

I think my problem lies with my environment variables somehow - how would I determine what the difference is between my environment variables in each case, and more importantly, how can I fix them in the su -c case?

1 Answer 1

2

You can find the difference between the environments like this:

su <user>
printenv

su <user> -c "printenv"

You can modify the environment in the second case like this:

su <user> -c "export <varname>=<varvalue>; <more commands...>"

Now for the specific problem I was having, I discovered that I needed the variable DB2INSTANCE set. So this worked for me:

su <user> -c "export DB2INSTANCE=<user>; /home/<user>/sqllib/bin/db2 catalog tcpip node <dbName> remote <ip> server <port>"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .