Link to home
Start Free TrialLog in
Avatar of LindaC
LindaCFlag for Puerto Rico

asked on

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
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Hi,

should be:

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

wmp


Avatar of LindaC

ASKER

Trying
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.
Avatar of LindaC

ASKER

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
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 ...?
Avatar of LindaC

ASKER

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
Why this harsh reaction? Did I offend you?

Anyway, did you try my last suggestion?
Avatar of LindaC

ASKER

Excuse me?  What harsh reaction.  I don't feel that way inside?  Did I said something wrong?

I'am trying your last posting.
Avatar of LindaC

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LindaC

ASKER

/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>