Script is not running: Solaris 5.8

Your "cron" job on centurion
/export/home/oracle/dba/scripts/sube_bd.sh

produced the following output:

/export/home/oracle/dba/scripts/sube_bd.sh: syntax error at line 1: `$' unexpect
ed




script:  sube_bd.sh

if $(ps -ef|grep [o]ra_pmon_ctimsd1|wc -l) -eq 0
then
  if [[ `ls /oradb/oravol01/* 2>/dev/null | wc -l` -gt 0 ]]
  then
        script /export/home/oracle/dba/logs/sube_bd.log
         date
         /export/home/oracle/dba/scripts/startctimsp1.sh
         sleep 60
         /export/home/oracle/dba/scripts/stopctimsp1.sh
         sleep 60
         /export/home/oracle/dba/scripts/startctimsp1.sh
         sleep 60
        exit
        exit 0
  fi
else
        exit 0
fi
LVL 8
LindaCAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

woolmilkporcCommented:
Hi,

should be:

if [[ $(ps -ef|grep [o]ra_pmon_ctimsd1|wc -l) -eq 0 ]]
  then ..

wmp


0
LindaCAuthor Commented:
Trying
0
woolmilkporcCommented:
And why do you alternate between $(  ) and backticks?

You could stay with the (better readable!)  $(  )  notation and use it in the second "if ..." as well:

  if [[ $(ls /oradb/oravol01/* 2>/dev/null | wc -l) -gt 0 ]]
    then ...

A minor mistake - the second "exit" here:

        exit
        exit 0

is useless - it wil never be reached.
0
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

LindaCAuthor Commented:
Received: (from oracle@localhost)
        by centurion.prt.local (8.11.7p1+Sun/8.10.2) id pBK7t0r21554
        for oracle; Tue, 20 Dec 2011 07:55:00 GMT
Date: Tue, 20 Dec 2011 07:55:00 GMT
From: oracle <oracle>
Message-Id: <201112200755.pBK7t0r21554@centurion.prt.local>
To: oracle
Subject: Output from "cron" command
Content-Type: text
Content-Length: 189

Your "cron" job on centurion
/export/home/oracle/dba/scripts/sube_bd.sh

produced the following output:

/export/home/oracle/dba/scripts/sube_bd.sh: syntax error at line 1: `(' unexpect
ed

sube-bd.txt
0
woolmilkporcCommented:
Which is your shell?

With some old shells you must use backticks, unfortunately:


if [[ `ps -ef|grep [o]ra_pmon_ctimsd1|wc -l` -eq 0 ]]
  then ..

and

 if [[ `ls /oradb/oravol01/* 2>/dev/null | wc -l` -gt 0 ]]
    then ...


You well used square brackets,  did you ...?
0
LindaCAuthor Commented:
woolmilkporc:  Answer:  I 'am an oracle dba.  I don't know much unix.  I just took a script that I saw in another server and try to do what I wanted to do which is trying to make this script work.  I have failed in this effort, so that is why I posted in this website, which I 'am paying mothly.  Hope you or someone can help me in this effort. Thank you.

/export/home/oracle/dba/scripts>echo $0
-ksh
0
woolmilkporcCommented:
Why this harsh reaction? Did I offend you?

Anyway, did you try my last suggestion?
0
LindaCAuthor Commented:
Excuse me?  What harsh reaction.  I don't feel that way inside?  Did I said something wrong?

I'am trying your last posting.
0
LindaCAuthor Commented:
From: oracle <oracle>
Message-Id: <201112200810.pBK8A0q22042@centurion.prt.local>
To: oracle
Subject: Output from "cron" command
Content-Type: text
Content-Length: 164

Your "cron" job on centurion
/export/home/oracle/dba/scripts/sube_bd.sh

produced the following output:

/export/home/oracle/dba/scripts/sube_bd.sh: [[: not found
0
woolmilkporcCommented:
OK,

seems that your system default shell ("bin/sh") is something quite different from ksh.

Please issue "which ksh" and add as the first line of the script "#!" directly followed by the result of "which ksh", probably:

#!/bin/ksh

Now issue

chmod +x /export/home/oracle/dba/scripts/sube_bd.sh

Now retry, it should work with backticks or $(  ), regardless.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LindaCAuthor Commented:
/var/mail>which ksh
/usr/bin/ksh

It worked now!  
Thanks so much, and Merry Christmas.

/export/home/oracle/dba/scripts>ps -ef|grep smon
  oracle 22601 21933  0 08:24:37 pts/1    0:00 grep smon
  oracle 22582     1  0 08:24:07 ?        0:00 ora_smon_ctimsd1
oracle@centurion[ctimsd1]<deadbeef>
/export/home/oracle/dba/scripts>ps -ef|grep lsnr
  oracle 22569     1  0 08:24:01 ?        0:00 /oradb/oravol01/app/oracle/produc
t/8.1.7/bin/tnslsnr LISTENER -inherit
  oracle 22603 21933  0 08:24:40 pts/1    0:00 grep lsnr
oracle@centurion[ctimsd1]<deadbeef>
/export/home/oracle/dba/scripts>
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.