Reputation: 3
I'm trying to figure out why the variable does not store the value of below command in the dev environment (AIX 6.1):
> DBSIZE=`db2 "CALL GET_DBSIZE_INFO(?, ?, ?, 0)" | grep -p DATABASESIZE
> | grep Value | cut -c21-`
If I execute echo $DBSIZE
it retrieves blank, without any value.
However, when I run only the command
db2 "CALL GET_DBSIZE_INFO(?, ?, ?, 0)" | grep -p DATABASESIZE | grep Value | cut -c21-
it retrieves the value.
Also, I executed the same in prod environment (AIX 6.1 also) and it works fine!
Any clue??
Thanks in advance.
Upvotes: 0
Views: 112
Reputation: 882316
Can't tell you what the exact problem is but, if you break it down into sections, you'll at least be able to identify where it's going wrong:
DBSIZE=`db2 "CALL GET_DBSIZE_INFO(?, ?, ?, 0)"`
echo "$DBSIZE"
DBSIZE=`db2 "CALL GET_DBSIZE_INFO(?, ?, ?, 0)" | grep -p DATABASESIZE`
echo "$DBSIZE"
DBSIZE=`db2 "CALL GET_DBSIZE_INFO(?, ?, ?, 0)" | grep -p DATABASESIZE | grep Value`
echo "$DBSIZE"
and so on.
One thing you may want to try (if that command is truly split across lines as shown) is to put in on one line. I seem to remember that some shells have trouble with embedded newlines inside backtick commands. If the first line can be seen as a complete command, it will sometimes treat it as two separate commands and the one starting with |
will cause a problem.
Upvotes: 1