LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-08-2009, 10:30 AM   #1
kais1
Member
 
Registered: Dec 2008
Posts: 61

Rep: Reputation: 17
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
 
Old 11-08-2009, 10:43 AM   #2
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Rep: Reputation: 234Reputation: 234Reputation: 234
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")
 
Old 11-08-2009, 10:49 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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?
 
Old 11-08-2009, 01:42 PM   #4
pcunix
Member
 
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 149

Rep: Reputation: 23
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).
 
Old 11-09-2009, 01:33 AM   #5
kais1
Member
 
Registered: Dec 2008
Posts: 61

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by catkin View Post
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
 
Old 11-09-2009, 07:49 AM   #6
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash line 74: syntax error: unexpected end of file help? andycol Linux - General 5 09-14-2009 08:12 AM
Parse error syntax error unexpected '{ ' on line chakaox Programming 2 04-29-2009 03:27 AM
Backup Script error "line 31: syntax error: unexpected end of file" eswanepoel General 7 12-07-2007 09:28 AM
/usr/bin/lesspipe: line 223: syntax error: unexpected end of file fakie_flip Linux - Software 1 09-06-2006 02:22 AM
got a syntax error which shows unexpected end of line when tried to run a shell scrip racer_mec Linux - Newbie 1 01-10-2005 01:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration