LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   syntax error at line 7 param unexpected (https://www.linuxquestions.org/questions/linux-newbie-8/syntax-error-at-line-7-param-unexpected-767703/)

kais1 11-08-2009 10:30 AM

syntax error at line 7 param unexpected
 
Dear all,

In a shell script.. am having the below contents..



#!/bin/sh
ORACLE_BASE=/meds/appl/oracle export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/102 export ORACLE_HOME
ORACLE_SID=TABS1
PATH=/usr/ccs/bin:$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:/meds/oracrs/product/102/bin
export PATH
DATE_SUFFIX=$(date +"%m-%d-%Y"_"%r")
tmpfile=/log/dbspace/MEDS_DBSPACE$DATE_SUFFIX.log"

when am trying to run this script, am getting the error
syntax error at line 7: `DATE_SUFFIX=$' unexpected

same DATE_SUFFIX=$(date +"%m-%d-%Y"_"%r") works fine in the command prompt..please advise what am missing ?


Kai

w1k0 11-08-2009 10:43 AM

I tried that script:

Code:

#!/bin/sh
DATE_SUFFIX=$(date +"%m-%d-%Y"_"%r")
echo $DATE_SUFFIX

In my case it works flawlessly.

Try something like:

Code:

DATE_SUFFIX="$(date +"%m-%d-%Y"_"%r")"
or something like:

Code:

DATE_SUFFIX=$(date +"%m-%d-%Y"_"%R":"%S")

catkin 11-08-2009 10:49 AM

I do not understand why you are getting that particular error (is the code an exact copy-and-paste?) but suggest regularising the quoting and the export commands
Code:

#!/bin/sh
export ORACLE_BASE=/meds/appl/oracle
export ORACLE_HOME=$ORACLE_BASE/product/102
ORACLE_SID=TABS1
export PATH="/usr/ccs/bin:$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:/meds/oracrs/product/102/bin"
DATE_SUFFIX="$(date '+%m-%d-%Y_%r')"
tmpfile="/log/dbspace/MEDS_DBSPACE$DATE_SUFFIX.log"

Is there any particular reason why you are using #!/bin/sh rather than #!/bin/bash?

pcunix 11-08-2009 01:42 PM

Are you sure you posted this correctly?

I only ask because

tmpfile=/log/dbspace/MEDS_DBSPACE$DATE_SUFFIX.log"

is obviously wrong (missing " at beginning).

kais1 11-09-2009 01:33 AM

Quote:

Originally Posted by catkin (Post 3749250)
I do not understand why you are getting that particular error (is the code an exact copy-and-paste?) but suggest regularising the quoting and the export commands
Code:

#!/bin/sh
export ORACLE_BASE=/meds/appl/oracle
export ORACLE_HOME=$ORACLE_BASE/product/102
ORACLE_SID=TABS1
export PATH="/usr/ccs/bin:$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:/meds/oracrs/product/102/bin"
DATE_SUFFIX="$(date '+%m-%d-%Y_%r')"
tmpfile="/log/dbspace/MEDS_DBSPACE$DATE_SUFFIX.log"

Is there any particular reason why you are using #!/bin/sh rather than #!/bin/bash?






Thanks all, that error fixed by using DATE_SUFFIX="$(date '+%m-%d-%Y_%r')"

now, the current code is :

#!/bin/bash
ORACLE_BASE=/meds/appl/oracle export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/102 export ORACLE_HOME
ORACLE_SID=meds1
PATH=/usr/ccs/bin:$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:/meds/oracrs/product/102/bin
export PATH
DATE_SUFFIX="$(date '+%m-%d-%Y_%r')"
tmpdir=/meds/work/log/dbspace
tmpfile="/meds/work/log/dbspace/meds_DBSPACE$DATE_SUFFIX.log"
sqlplus username/password@meds1 as sysdba <<EOF
set termout off
set timing on
spool $tmpfile
@/meds/scripts/dbspace.sql
spool off
exit
EOF




now, the spool file is not getting passed inside sqlplus and am getting the error :


SQL> SQL> SQL> SP2-0332: Cannot create spool file.
SQL> SQL> not spooling currently



Any idea ?


Kai

timmeke 11-09-2009 07:49 AM

Have you tried performing the block
Code:

sqlplus username/password@meds1 as sysdba <<EOF
set termout off
set timing on
spool $tmpfile
@/meds/scripts/dbspace.sql
spool off
exit
EOF

manually for a specific $tmpfile?
If $tmpfilie and the SQL commands are right, then it may just be an issue of
mysqlplus trying to create a spool file in a folder where you do not have write permission.

Try setting $tmpfile to a filename in a path that you know you have write permission on, like in your home directory.
Then perform the block, and see if sqlplus shows the error.

Also, a quick Google search turned up the Oracle online docs, where you can consult what error SP2-0332
really is about.
http://docs.oracle.com


All times are GMT -5. The time now is 07:29 AM.