Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Posts
    17

    Unanswered: How to resolve this problem

    Following is my shell :
    d=$(date "+%y:%m:%d:%H:%M:%S")
    i=0
    for dbname in $(cat $MONCONF/db_name|head -n 200)
    do (
    result=`remsh dbsvr1 ". /home/db2inst2/sqllib/db2profile;db2 get snapshot for all on $dbname"`
    echo $result|grep "High water mark for connections">1.txt
    )
    ((i=i+1))
    done

    when I execute this shell,the error is generated:
    grep: 0652-226 Maximum line length of 2048 exceeded.
    How to resolve it?
    Thanks!

  2. #2
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525
    remsh dbsvr1 ". /home/db2inst2/sqllib/db2profile;db2 get snapshot for all on $dbname" | grep "High water mark for connections">1.txt

    or

    result=`remsh dbsvr1 ". /home/db2inst2/sqllib/db2profile;db2 get snapshot for all on $dbname"`
    echo "$result" |grep "High water mark for connections">1.txt

  3. #3
    Join Date
    Jul 2004
    Posts
    17
    It is done.
    However,when I modify the shell as followings:
    d=$(date "+%y:%m:%d:%H:%M:%S")
    i=0
    for dbname in $(cat $MONCONF/db_name|head -n 200)
    do (
    result=`remsh dbsvr1 ". /home/db2inst2/sqllib/db2profile;db2 get snapshot for all on $dbname"`
    echo $result|grep -E "High water mark for connections|database name">1.txt
    )
    ((i=i+1))
    done

    the following error occurs.
    ./db2_connect.sh[10]: 0403-029 There is not enough memory available now.
    ./db2_connect.sh[6]: 0403-029 There is not enough memory available now.
    grep: 0652-226 Maximum line length of 2048 exceeded.

    Why?
    What's the differenc between "$result" and $result?

  4. #4
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525
    Quotes are *very* important in Unix. You should probably read up on them because the way you quote anything, using single quotes, double quotes, backticks and/or any combination of these can produce completely different results.

    In this example, not quoting $result, causes the shell to perform variable expansion on $result, the resulting string is then tokenised using the values held in the environment variable $IFS ( by default a space, a tab and a newline ). Effectively, this means that all the spaces, tabs and newlines in $result would be lost and replaced with a single space. Using quotes would cause $result to be treated as a single token, thus retaining the embedded spaces, tabs and newlines.

    e.g.

    $ var="a
    $ b
    $ c"
    $ echo $var
    a b c
    $ echo "$var"
    a
    b
    c

  5. #5
    Join Date
    Jul 2004
    Posts
    17
    thanks a lot.
    I have understand the importance of double quota.
    However,how to resolve this problem
    the following error occurs.
    ./db2_connect.sh[10]: 0403-029 There is not enough memory available now.
    ./db2_connect.sh[6]: 0403-029 There is not enough memory available now.
    grep: 0652-226 Maximum line length of 2048 exceeded.

    Why?

Posting Permissions

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