aix logon

how do I create a script to logon to db2inst1 with a password , then issue db2 command :frowning:

That depends on which means to log on to the machine you want to use. You could use:

rexec/rcmd
rlogin
telnet
ssh

and perhaps some more. IMHO you should opt for some securized form of logging on (which leaves only ssh), but, depending on your environment, any other tools might equally suffice. Some of these tools have kerberized (Kerberos-aware) variants which might or might not be necessary for you (in the nowadays unlikely case you have a Kerberos domain set up).

If you could elaborate on what your requirements are we might be better able to help you. As you have asked a very general question the answer is also quite general in nature.

I hope this helps.

bakunin

I have a sh file... batch.sh. within the sh file I want to logon to user ID db2inst1. but I do not want to use the su command

Why not the su command? You can use

su -c

to issue one command as another user.

I am trying to DB2 SQL command and am having problem with the SQL... i have been using su -c db2inst1 'db2 "select ....." ' however if the SQL have '||' with the sql this seems to cause a problem

create a authorized key connection from you machine to db2 server, put the public key from your source host to $HOME/.ssh/authorized_keys on the db2 Server (this is default, may be different on your system)

then try

ssh db2inst1@host << _EOF

#yoursqlstatement

_EOF