Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

case 1

Status
Not open for further replies.

230173

MIS
Jun 22, 2001
208
SG
We needed a new backup script so i took the script that's in the book.(Backup & recovery by Rama Velpuri) (On a RS6000 machine with AIX 4.3.3)
But i'm not good at scripting and i get this error message: "No such database"
So it goes wrong at this line:

case $1 in bkup_tst) ....

Wat does this mean?

He goes right to => *) echo "No such database";


this is a copy of the script:

case $1 in
bkup_tst) ORACLE_HOME=/opt/app/oracle/product/8.1.7; # This is my oracle home
ORACLE_SID=bkup_tst; # ???
PATH=/usr/bin:/usr/sbin:$ORACLE_HOME/bin ; # nothing changed here
# EXPORTDIROLD=/oradata9/${1}/backup/
Test_backup_old/old_export; # I made these dirs
EXPORTDIR=/oradata9/${1}/backup/
Test_export; # ok
BACKUPDIR=/oradata9/${1}/backup/ Test_backup; # ok
# BACKUPDIROLD=/oradata9/${1}/backup/ Test_old_backup; # ok
ARCOLD=/oradata9/${1}/backup/Test_archive; # ok
;;

*) echo "No such database";
exit 1 ;;
esac

Thanks,
 
The case statement is much the same as an if .. then .. else statement only it's a bit neater. The code you see above basically says ...

if $1 = bkup_tst
then
do something
else
echo "No such database"
endif

Say a variable had 5 possible values ... you could either say
Code:
if var = 1
then
   do stuff
else
   if var = 2
   then 
      do stuff
   else
      if var = 3
      then
         do stuff
      else
         if var = 4
         then
            do stuff
         else
            if var = 5
            then
               do stuff
            else
               do something else
            endif
         endif
      endif
   endif
endif
or you can say (for ksh)
case var in
1)
do stuff
;;
2)
do stuff
;;
3)
do stuff
;;
4)
do stuff
;;
5)
do stuff
;;
*)
do stuff
;;
esac
[/b]
Simple really :)

Greg.
 
Looks like a typo ....

case $1 in
bkup_tst)

<SNIP>

*) echo &quot;No such database&quot;;
exit 1 ;;
esac
-------------------
bkup_tst( ***************************************
Party on, dudes!
[cannon]
 
What is the value if the 1st parameter passed to the script? If it isn't bkup_tst then you'll get the &quot;No such database&quot; message.

Greg.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top