Input passwords automatically in shell script

From: Ram <krishna000_at_gmail.com>
Date: Wed, 18 Nov 2009 20:59:10 -0800 (PST)
Message-ID: <b171b539-ad20-403c-8a26-8480f2addbff_at_z35g2000prh.googlegroups.com>



Hi all,

I have one shell script which is scheduled in cron to restart Oracle BI Publisher every day night _at_ 1:00 AM . Even after restarting end users complaints that , they don't receive scheduled reports mails . So i am plannig to kill all the sessions of that user from cronjob itself .

My shell script looks like this

0 1 * * * /patches/BI_Publisher/restart.sh 2>&1 >> /patches/ BI_Publisher/restart.log

export ORACLE_HOME=/patches/BI_Publisher/OraHome_1

/patches/BI_Publisher/OraHome_1/jdk/bin/java -jar /patches/ BI_Publisher/OraHome_1/oc4j_bi/j2ee/home/admin.jar ormi://localho st:23791 oc4jadmin bipub1 -shutdown force

if [ $? -ne 0 ]
then
echo " Stop Failed \n "
else
echo " Success "
fi

nohup /patches/BI_Publisher/OraHome_1/oc4j_bi/bin/oc4j -start &

if [ $? -ne 0 ]
then
echo " Start Failed \n "
else
echo " Success "
fi



So inorder to achieve i have tried using this command in this shell script

ps -ef | grep -i bipub | awk '{ print $2; }'|grep -v $$|xargs kill -9

But this kills all sessions and now i want do su to bipub user automatically to start the services . To achive this I want to input password automaticaly to do su - bipub .

I have tried googling but i am not getting good hits with good explanation.

Can any one please help me out.

Regards. Received on Wed Nov 18 2009 - 22:59:10 CST

Original text of this message