![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do i change to super user then revert back to ordinary user ,using shell script? | wrapster | Shell Programming and Scripting | 3 | 06-04-2008 04:11 AM |
| su (switching to other user) | bjagadeesh | Shell Programming and Scripting | 1 | 05-20-2008 07:27 AM |
| [Help] Give privilege to an ordinary user | ibmer414 | AIX | 1 | 04-08-2008 11:56 AM |
| switching between root and a normal user | melanie_pfefer | Shell Programming and Scripting | 3 | 04-21-2007 04:02 AM |
| Other than root user .Normal user is unable to create files | mallesh | UNIX for Advanced & Expert Users | 1 | 06-22-2005 09:18 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
switching user from root to ordinary user
Good day Guys!!!
I am currently making a script in AIX, the script runs a SAS job, the owner of the script is the root, but the SAS jobs cannot be run by the root, as it should be run by a user 'sasia'. But inside the script, root creates a logfile, so what I need is just to su to sasia for the certain job and then go back to the original user. the script is written below. Pls. help #!/bin/sh function logrc { if [ -f $drv/$batchname".err" ] then cat $drv/$batchname".err"|grep 0 rcode=$? fi echo $step $rcode $dtx $bpsw $desc >> $drv/$batchname".log" if [ $bpsw != 1 ] then if [ $rcode != 0 ] then echo >> $drv/$batchname".log" echo "Job Failed at "$step"." >> $drv/$batchname".log" echo "Recovery Procedure:" >> $drv/$batchname".log" if [ -f $rdrv/$batchname".rpm" ] then cat $rdrv/$batchname".rpm" >> $drv/$batchname".log" else echo "No Recovery Procedure." >> $drv/$batchname".log" fi exit $rcode fi fi return $rcode } function step00 { step=step00 desc="Delete exisitng trigger files" cd /sasprog/triggers if [ -f $st ] then rm $st echo $st " deleted " else echo $st" does not exist" fi if [ -f $ut ] then rm $ut echo $ut " deleted" else echo $ut " does not exist" fi echo date rcode=$? logrc } function step01 { step=step01 if [ "$rrstep" != "" ] && [ "$rrstep" != "$step" ] then echo $step skipped return 0 fi desc="Call SAS job" Quoteme() { if [ $# -gt 1 ]; then quoteme="\"$*\"" else quoteme=$1 fi } cd `cat /sasconfig/BPICRMS/jobpath/prereq` cmd="/sas9/SAS913/sas" for arg in "SET_RUN_CONTROL_TABLE_FOR_ALAS.sas" do Quoteme $arg tmp="$quoteme" cmd="$cmd $tmp" done $cmd rcode=$? logrc } #main script drv=/sasprog/joblog rdrv=/sasprog/Lev1/rdrv batchname=SET_RUN_CONTROL_TABLE_FOR_ALAS dtx=`date +'%y%m%d'`" "`date +'%H%M%S'` rrstep="" bpsw=0 ut=U_SET_RUN_CONTROL_TABLE_FOR_ALAS.txt st=S_SET_RUN_CONTROL_TABLE_FOR_ALAS.txt if [ "$1" != "" ] && [ "$1" != "step00" ] then echo Job Restarted at $1 $dtx >> $drv/$batchname".log" rrstep=$1 else echo Job Started $dtx > $drv/$batchname".log" rrstep="" fi step00 step01 exit $rcode what I need is to revise the functyion 01 so that it will switch user to sasia, run the sasjob and then go back as root. Thanks in advanced for the help. Thanks #end of script |
| Forum Sponsor | ||
|
|