LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sntax error : unexpected end of file while executing shell script (http://www.linuxquestions.org/questions/linux-newbie-8/sntax-error-unexpected-end-of-file-while-executing-shell-script-719989/)

priyankarathi 04-18-2009 04:36 AM

Sntax error : unexpected end of file while executing shell script
 
hello

Posting for first time :)
Actually I have written a shell script to take RMAN backup..
But when I execut it I get an error as

"syntax error: unexpected end of file"

Script:

if [ -n $1 ]; then
echo $1
backup=$1
fi

if [ $1="full" ]; then
rman target / <<ST
run {
allocate channel ch0 type sbt_tape;
backup full database;
release channel ch0;
}
ST
echo backup completed
fi


Can someone please help me out..
Actually m new at shell scripting

druuna 04-18-2009 05:14 AM

Hi,

I'm not familiar with rman (we are talking about Oracle's Recovery Manager aren't we?), but a quick search tells me that your syntax is not correct. You don't need the run { } syntax (untested, don't have rman present):
Code:

.
.
.
then
  rman target / <<ST
  allocate channel ch0 type sbt_tape;
  backup full database;
  release channel ch0;
ST
.
.
.

Take a look here: An Introduction to Linux Shell Scripting for DBAs

And here for a different approach: RMAN command from script

Hope this helps.

priyankarathi 04-20-2009 12:05 AM

Hello,

You r right ..RMAN is recovery manager
Thanks for the reply..
But i had alraedy tried it...
Its not working..

Can somebaody help me

druuna 04-20-2009 03:18 AM

Hi again,

What did you try? My suggestion and the tips/hints/examples in the provided links? And none work?

What are the errors do you encounter and if at all possible could you post the entire script.

colucix 04-20-2009 03:50 AM

One of the most common errors is the indentation of the string at the end of the here documents:
Code:

rman target / <<ST
run {
allocate channel ch0 type sbt_tape;
backup full database;
release channel ch0;
}
ST  ### This must be at the beginning of the line


priyankarathi 04-21-2009 02:33 AM

Heyy!!!!

Actually the problem was not with the script...
Actually I was doing indentation for RMAN script when called in function..
i.e

funbackup ()
{
rman target / <<ST
backup....
....
}

Actually it shud be
funbackup ()
{
rman target / <<ST
backup....
....
}

this was creating problemmm
But i solved it by trial and error.. :)


All times are GMT -5. The time now is 04:12 AM.