datafan Posted February 15, 2008 Share Posted February 15, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/91336-simple-shell-script-problem-simple-yeah-right/ Share on other sites More sharing options...
effigy Posted February 15, 2008 Share Posted February 15, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/91336-simple-shell-script-problem-simple-yeah-right/#findComment-468068 Share on other sites More sharing options...
datafan Posted February 19, 2008 Author Share Posted February 19, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/91336-simple-shell-script-problem-simple-yeah-right/#findComment-470175 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.