L
Laarni
Hi,
Im trying to convert c shell script to PERL but haven't use PERL
before can anybody help me on this? Thanks in advance.
#! /bin/csh
if ($#argv <= 2) then
echo "Usage : $0 <table_name> <config_file> <config_file_2>"
exit
endif
set table = $argv[1]
set config_file = $argv[2]
set config_file_2 = $argv[3]
source $config_file
if ( $#argv >= 3 ) then
if (-f $config_file_2) then
source $config_file_2
endif
endif
if !(-d $backup) then
echo ""
echo "Create backup directory..."
mkdir $backup
endif
if !(-d $backup/$DB) then
echo ""
echo "Create backup directory for database..."$DB
mkdir $backup/$DB
endif
bcp $DB..$table out $backup/$DB/$table -c -U$UID -P$PSW -S$SVR
echo " Rename table..."
sed -e s/table/$table/g modify_rename_table.sql | runsql
#! /bin/csh
if ($#argv <= 2) then
echo "Usage : $0 <table_name> <config_file> <config_file_2>"
exit
endif
set table = $argv[1]
set config_file = $argv[2]
set config_file_2 = $argv[3]
source $config_file
if ( $#argv >= 3 ) then
if (-f $config_file_2) then
source $config_file_2
endif
endif
if !(-d $backup) then
echo ""
echo "Create backup directory..."
mkdir $backup
endif
if !(-d $backup/$DB) then
echo ""
echo "Create backup directory for database..."$DB
mkdir $backup/$DB
endif
bcp $DB..$table out $backup/$DB/$table -c -U$UID -P$PSW -S$SVR
echo " Rename table..."
sed -e s/table/$table/g modify_rename_table.sql | runsql
if (-f $table.convert.sql) then
echo " Converting temp table..."
runsql < $table.convert.sql
endif
echo " Recreate table..."
if (-f $newtabdir/$table.tab.sql) then
runsql < $newtabdir/$table.tab.sql
else
if (-f $alt1tabdir/$table.tab.sql) then
runsql < $alt1tabdir/$table.tab.sql
else
if (-f $alt2tabdir/$table.tab.sql) then
runsql < $alt2tabdir/$table.tab.sql
else
if (-f $alt3tabdir/$table.tab.sql) then
runsql < $alt3tabdir/$table.tab.sql
else
if (-f $alt4tabdir/$table.tab.sql) then
runsql < $alt4tabdir/$table.tab.sql
else
if (-f $alt5tabdir/$table.tab.sql) then
runsql < $alt5tabdir/
$table.tab.sql
endif
endif
endif
endif
endif
endif
echo " Copy data..."
if (-f $table.copy.sql) then
runsql < $table.copy.sql
else
if (-f $table.select.sql) then
sed -e s/table/$table/g modify_copy_data.sql | sed -e s/\*/`cat
$table.select.sql`/g | runsql
else
sed -e s/table/$table/g modify_copy_data.sql | runsql
endif
endif
echo " Drop temp table..."
runsql < modify_drop_temp.sql
source ../PROMOTE.uncfg
Regards,
Laarni
Im trying to convert c shell script to PERL but haven't use PERL
before can anybody help me on this? Thanks in advance.
#! /bin/csh
if ($#argv <= 2) then
echo "Usage : $0 <table_name> <config_file> <config_file_2>"
exit
endif
set table = $argv[1]
set config_file = $argv[2]
set config_file_2 = $argv[3]
source $config_file
if ( $#argv >= 3 ) then
if (-f $config_file_2) then
source $config_file_2
endif
endif
if !(-d $backup) then
echo ""
echo "Create backup directory..."
mkdir $backup
endif
if !(-d $backup/$DB) then
echo ""
echo "Create backup directory for database..."$DB
mkdir $backup/$DB
endif
bcp $DB..$table out $backup/$DB/$table -c -U$UID -P$PSW -S$SVR
echo " Rename table..."
sed -e s/table/$table/g modify_rename_table.sql | runsql
#! /bin/csh
if ($#argv <= 2) then
echo "Usage : $0 <table_name> <config_file> <config_file_2>"
exit
endif
set table = $argv[1]
set config_file = $argv[2]
set config_file_2 = $argv[3]
source $config_file
if ( $#argv >= 3 ) then
if (-f $config_file_2) then
source $config_file_2
endif
endif
if !(-d $backup) then
echo ""
echo "Create backup directory..."
mkdir $backup
endif
if !(-d $backup/$DB) then
echo ""
echo "Create backup directory for database..."$DB
mkdir $backup/$DB
endif
bcp $DB..$table out $backup/$DB/$table -c -U$UID -P$PSW -S$SVR
echo " Rename table..."
sed -e s/table/$table/g modify_rename_table.sql | runsql
if (-f $table.convert.sql) then
echo " Converting temp table..."
runsql < $table.convert.sql
endif
echo " Recreate table..."
if (-f $newtabdir/$table.tab.sql) then
runsql < $newtabdir/$table.tab.sql
else
if (-f $alt1tabdir/$table.tab.sql) then
runsql < $alt1tabdir/$table.tab.sql
else
if (-f $alt2tabdir/$table.tab.sql) then
runsql < $alt2tabdir/$table.tab.sql
else
if (-f $alt3tabdir/$table.tab.sql) then
runsql < $alt3tabdir/$table.tab.sql
else
if (-f $alt4tabdir/$table.tab.sql) then
runsql < $alt4tabdir/$table.tab.sql
else
if (-f $alt5tabdir/$table.tab.sql) then
runsql < $alt5tabdir/
$table.tab.sql
endif
endif
endif
endif
endif
endif
echo " Copy data..."
if (-f $table.copy.sql) then
runsql < $table.copy.sql
else
if (-f $table.select.sql) then
sed -e s/table/$table/g modify_copy_data.sql | sed -e s/\*/`cat
$table.select.sql`/g | runsql
else
sed -e s/table/$table/g modify_copy_data.sql | runsql
endif
endif
echo " Drop temp table..."
runsql < modify_drop_temp.sql
source ../PROMOTE.uncfg
Regards,
Laarni