Jump to content

Recommended Posts

ok, when I run this script and get to the db2 stuff, it works only for the two db2 commands that specify the user(scminsta) and password. On all the other db2 commands I get "ROOT    " does not have the authority to perform the requested command.

 

I am not sure how to say this, but how can I get the script to "stay" with the db2 user and not default back to root until the quit command runs? Thanks for any ideas even, I can't find any info on this.

 

#A bunch of stuff runs as ROOT, then:

. /home/scminsta/sqllib/db2profile  #this sets an environment for the db2 user scminsta 

db2 "connect to jac user scminsta using password"  #this line runs fine
db2 "force applications all" #all the rest of these lines try to run as ROOT user and fail
db2 "db2stop"
db2 "db2start"
db2 "backup database jac user scminsta using password to $TMP_DIR"  #this line runs fine
db2 "force applications all"
db2 "db2stop force"
db2 "db2start"
db2 "quit"


#Now some stuff runs as ROOT. 

It seems that db2 is the problem, not the shell. Perhaps a stop wipes away the previous user's information and it needs to be reloaded?

 

There are some results here: http://www.google.com/search?hl=en&q=db2+command+line&btnG=Search

I finally figured it out, it jumps out of the  "root" shell to the "scminsta" shell and as soon as it's done running that particular command it jumps back into the "root" shell.

 

Here is the solution:

 

#!/bin/sh
A bunch of stuff runs as ROOT, then:

db2 "connect to jac user scminsta using password"
su - scminsta -c db2 "force applications all"
su - scminsta -c db2 "db2stop"
su - scminsta -c db2 "db2start"
db2 "backup database jac user scminsta using password to $TMP_DIR" >> $LOG 2>&1
su - scminsta -c db2 "force applications all"
su - scminsta -c db2 "db2stop"
su - scminsta -c db2 "db2start"
su - scminsta -c db2 "quit"

#Now some stuff runs as ROOT.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.