Help on Perl Scripting

Discussion in 'Perl Misc' started by Laarni, Jan 10, 2008.

  1. Laarni

    Laarni Guest

    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
    Laarni, Jan 10, 2008
    #1
    1. Advertising

  2. Gunnar Hjalmarsson, Jan 10, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,772
  2. Mark
    Replies:
    3
    Views:
    594
    Joe Smith
    Mar 18, 2005
  3. Ron Stephens
    Replies:
    23
    Views:
    2,800
    Ron Stephens
    Apr 12, 2004
  4. DaveInSidney
    Replies:
    0
    Views:
    402
    DaveInSidney
    May 9, 2005
  5. Mark
    Replies:
    1
    Views:
    78
    Arndt Jonasson
    Mar 18, 2005
Loading...

Share This Page