The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
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 08:11 AM
su (switching to other user) bjagadeesh Shell Programming and Scripting 1 05-20-2008 11:27 AM
[Help] Give privilege to an ordinary user ibmer414 AIX 1 04-08-2008 03:56 PM
switching between root and a normal user melanie_pfefer Shell Programming and Scripting 3 04-21-2007 08:02 AM
Other than root user .Normal user is unable to create files mallesh UNIX for Advanced & Expert Users 1 06-22-2005 01:18 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 01-24-2008
sasia sasia is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 4
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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:24 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0