LindaC
asked on
Script is not running: Solaris 5.8
Your "cron" job on centurion
/export/home/oracle/dba/sc ripts/sube _bd.sh
produced the following output:
/export/home/oracle/dba/sc ripts/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/lo gs/sube_bd .log
date
/export/home/oracle/dba/sc ripts/star tctimsp1.s h
sleep 60
/export/home/oracle/dba/sc ripts/stop ctimsp1.sh
sleep 60
/export/home/oracle/dba/sc ripts/star tctimsp1.s h
sleep 60
exit
exit 0
fi
else
exit 0
fi
/export/home/oracle/dba/sc
produced the following output:
/export/home/oracle/dba/sc
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/lo
date
/export/home/oracle/dba/sc
sleep 60
/export/home/oracle/dba/sc
sleep 60
/export/home/oracle/dba/sc
sleep 60
exit
exit 0
fi
else
exit 0
fi
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.
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.
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/sc ripts/sube _bd.sh
produced the following output:
/export/home/oracle/dba/sc ripts/sube _bd.sh: syntax error at line 1: `(' unexpect
ed
sube-bd.txt
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
To: oracle
Subject: Output from "cron" command
Content-Type: text
Content-Length: 189
Your "cron" job on centurion
/export/home/oracle/dba/sc
produced the following output:
/export/home/oracle/dba/sc
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 ...?
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 ...?
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/sc ripts>echo $0
-ksh
/export/home/oracle/dba/sc
-ksh
Why this harsh reaction? Did I offend you?
Anyway, did you try my last suggestion?
Anyway, did you try my last suggestion?
ASKER
Excuse me? What harsh reaction. I don't feel that way inside? Did I said something wrong?
I'am trying your last posting.
I'am trying your last posting.
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/sc ripts/sube _bd.sh
produced the following output:
/export/home/oracle/dba/sc ripts/sube _bd.sh: [[: not found
Message-Id: <201112200810.pBK8A0q22042
To: oracle
Subject: Output from "cron" command
Content-Type: text
Content-Length: 164
Your "cron" job on centurion
/export/home/oracle/dba/sc
produced the following output:
/export/home/oracle/dba/sc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
/var/mail>which ksh
/usr/bin/ksh
It worked now!
Thanks so much, and Merry Christmas.
/export/home/oracle/dba/sc ripts>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/sc ripts>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/sc ripts>
/usr/bin/ksh
It worked now!
Thanks so much, and Merry Christmas.
/export/home/oracle/dba/sc
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]<
/export/home/oracle/dba/sc
oracle 22569 1 0 08:24:01 ? 0:00 /oradb/oravol01/app/oracle
t/8.1.7/bin/tnslsnr LISTENER -inherit
oracle 22603 21933 0 08:24:40 pts/1 0:00 grep lsnr
oracle@centurion[ctimsd1]<
/export/home/oracle/dba/sc
should be:
if [[ $(ps -ef|grep [o]ra_pmon_ctimsd1|wc -l) -eq 0 ]]
then ..
wmp