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!

why why why???? script reading

Status
Not open for further replies.

230173

MIS
Jun 22, 2001
208
SG
Now we needed a new backup script so i took the script that's in the book. (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,
 
$1 is a variable (the 1st) given when the script is called.




'case' is like 'switch' in Language C
bkup_tst) means if $1 is equal to bkup_tst do the following lines ...

You have to put the name of your instance ( ORACLE_SID)

*) means other case



 
Scripting can get pretty complicated fast, I recommend the O'Reilly Korn Shell book.
 
To be a bit clearer for you, $1 equates to the first paramater passed to your script from the command line.

For example, if you were to type

my_script fred bloggs

at the command line, where the script is called "my_script"

$1 would = fred and
$2 would = bloggs.

That point in the script you have tested is checking to see whether you have typed

backup_script bkup_tst

at the command line. If you did not (and it seems that you didn't) then the case statement performs the *) section.

Hope that helps
LHLTech

IBM Certified Specialist - AIX System Support
Halfway through CATE exams!
 
$? is the status of the command after completion. A value of 0 (zero) usually indicates success, non-zero failure of some kind. You can check the status using echo $?

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top