Re: Input passwords automatically in shell script

From: Steve Howard <stevedhoward_at_gmail.com>
Date: Thu, 19 Nov 2009 12:06:20 -0800 (PST)
Message-ID: <7cb1d12c-f02b-438b-bbca-9fd5fef64bc3_at_o13g2000vbl.googlegroups.com>



On Nov 18, 11:59 pm, Ram <krishna..._at_gmail.com> wrote:
> 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.

Hi,

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

HTH, Steve Received on Thu Nov 19 2009 - 14:06:20 CST

Original text of this message