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?
 
woolmilkporcConnect With a Mentor Commented:
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
 
woolmilkporcCommented:
Hi,

should be:

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

wmp


0
 
LindaCAuthor Commented:
Trying
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
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
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.