Quote:
|
Originally Posted by rozihan
#! /usr/bin/csh -f
|
There should be no space between ! and /
else the default Bourne shell is used
Quote:
|
Originally Posted by rozihan
isql -Usa -P -SSYBASEKK
|
You are not using the
<<label See post
#2 and
#5 by Tyveleyn
Don't write C shell scripts. See
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
http://www.grymoire.com/Unix/CshTop10.txt
For Bourne type shells Sybase provide environment settings in SYBASE.sh
ksh script below
Code:
#!/usr/bin/ksh
dbname=$1 # 1st parameter is the database name
dumpdir=$2 # 2nd parameter is dump directory
scriptname=${0##*/} # remove path from script name
if [ "$2" = "" ]
then
echo "Error: missing parameter"
echo "Syntax: $scriptname <dbname> <backup_dir>"
exit 8
fi
logfile=/tmp/"$scriptname"."$dbname".log$$
. /usr/syb1253/SYBASE.sh # sybase env (Note dot space slash)
isql -Usa -P -SSYBASEKK <<EOF >"$logfile"
dump database $dbname to "compress::$dumpdir/$dbname.dgz"
go
EOF
if [ "$(grep 'DUMP is complete' $logfile )" = "" ]
then
echo dump database "$dbname" failed see "$logfile"
exit 12
fi
I suggest you rename dbfile1 to e.g. sybdump1
Then to backup mydb to /backup/sybdumps run e.g.
./sybdump1 mydb /backup/sybdumps
And to execute from cron specify the full path to your script e.g.
30 18 * * * /mydir/scripts/sybdump1 mydb /backup/sybdumps