Results 1 to 5 of 5
  1. #1
    Join Date
    May 2013
    Posts
    5

    Unanswered: Unable to extract tablespace ddl using db2look in shell script

    Hi,

    I am using this shell script

    #!/bin/bash
    dbname=$1
    schema=$2
    table=$3
    tbspace=EMP_201305
    datatbsmon=201305
    newmon=201306
    db2look -d $dbname -l -z $schema - t $table|grep -ip $tbspace|sed 's/'$datatbsmon'/'$newmon'/' > tbs.ddl

    (the tablespace names are like xxxxxx_201305 where 201305 denotes year and month)

    after i execute this shell script (using sh script.sh sampledb EMPLOYEE EMP_DATA),...... tbs.ddl is empty file and it shows nothing.

    But when I execute the below command in command prompt,

    db2look -d sampledb -l -z Employee -t EMP_DATA|grep -ip EMP_201305|sed 's/201305/201306/g' > tbs.ddl

    tbs.ddl has the ddl for the tablespace EMP_201306.

    Please help me resolve this issue as i need to create the new tablespace based on the naming convention of the previous tablespace and I need to do it using shell script.

    Thanks,
    Rupesh.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Was there any console output between the time you started the script and the time that the next prompt appeared on your screen?

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    May 2013
    Posts
    5
    yes, there was output displayed on the console from db2look........ the first few commented lines of db2look like

    --User was not mentioned blah blah

    -- Schema ignored for federated tables etc.
    Last edited by 333rupesh; 05-11-13 at 14:27.

  4. #4
    Join Date
    Jan 2009
    Location
    United Kingdom
    Posts
    77
    Have you tried to output the following line in the shell script with the values and confirmed whether the command is properly formatted ?

    db2look -d $dbname -l -z $schema - t $table|grep -ip $tbspace|sed 's/'$datatbsmon'/'$newmon'/' > tbs.ddl

  5. #5
    Join Date
    May 2013
    Posts
    5
    yes, I did

    echo "db2look -d $dbname -l -z $schema - t $table|grep -ip $tbspace|sed 's/'$datatbsmon'/'$newmon'/' > tbs.ddl"

    and this displayed me the correct values and also they were properly formatted.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •