Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Input passwords automatically in shell script

1 view
Skip to first unread message

Ram

unread,
Nov 18, 2009, 11:59:10 PM11/18/09
to
Hi all,

I have one shell script which is scheduled in cron to restart Oracle
BI Publisher every day night @ 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.

gazzag

unread,
Nov 19, 2009, 5:38:47 AM11/19/09
to

If the cron runs as root, you won't need to supply a password.
Simply run the relevant shell-script as follows:

su - bipub -c <shell_script>

HTH

-g

Steve Howard

unread,
Nov 19, 2009, 3:06:20 PM11/19/09
to

Hi,

In addition to gazzag's reply, you can also google "Expect password"
without the quotes.

HTH,

Steve

0 new messages