Results 1 to 2 of 2

Thread: Script help

  1. #1
    Join Date
    Aug 2016
    Posts
    20
    Provided Answers: 1

    Unanswered: Script help

    Hi

    running from root user ,


    #su - db2inst1-c 'db2 list db directory | awk -v RS='' '/Indirect/' ' | grep -i 'Database name' | awk ' { print "su - db2inst1-c db2 activate db " $NF } '
    su - db2inst1-c db2 activate db SAMPLE1
    su - db2inst1-c db2 activate db SAMPLE


    need to get codes to run this desired output

    su - db2inst1-c 'db2 activate db SAMPLE1'
    su - db2inst1-c 'db2 activate db SAMPLE'


    any help

    regards
    paul

  2. #2
    Join Date
    Jul 2016
    Location
    Moscow
    Posts
    112
    Provided Answers: 13
    Hi,

    If the goal is to activate all the local databases, then try this:
    Code:
    su - db2inst1 -c "db2 list db directory | awk -v RS='\n\n' '/Indirect/' | grep '^ Database name' | cut -d'=' -f2 | while read db; do db2 activate db \${db}; done"
    Regards,
    Mark.

Posting Permissions

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