Originally posted by: GregMarino
Thanks for the reply...
The second time I run it without any parameters:
. testme
I want $1 to actually be blank. But it is not - it is retaining the previous value "YOU"
So the real question is : How do I get $1 unset? And don't suggest to run it like this:
. testme ""
cause that causes another problem. My real script tests for both the existance of $1 and it's contents of present...and if $1 does not equal a specific value, then you get and error.
Here - put this in your testme script:
<hr />
echo 1=$1
if [
then
if [
then
echo "There was at least 1 Parameter passed into this script and \$1 was not \"DB\" "
else
echo "There was at least 1 Parameter passed into this script and \$1 was \"DB\" "
fi
else
echo "There were no parameters passed into this script"
fi
<hr />
Now run these commands and observer the output (the output is based on the assumption you have not already "contaminated" your session:
. testme There were no parameters passed into this script . testme DB There was at least 1 Parameter passed into this script and $1 was "DB" . testme There was at least 1 Parameter passed into this script and $1 was "DB" . testme "" There was at least 1 Parameter passed into this script and $1 was not "DB" This is NOT the behavior I need.
And since you asked (not), I have attached the actual script that I am trying to run -
db2_env.ksh This script sets the environment parameters needed for db2 to run properly in your session. This is accomplished by dot-running the
$INSTHOME/sqllib/db2profile script. On many servers, we have many db2 instances. So this script finds all available db2 instances, displays a list of them and then allows you to choose which db2 instance you want to switch to for your session.
So in order for the db2profile to set the environment in your current session, you must dot-run this script.
This script has an "enhanced feature" which also allows you to see what databases are available in each instance. To trigger this functionality, you pass in an
optional parameter. The problem is, once you trigger the functionality by typing
. db2_env.ksh DB you can never run the script again
without the trigger since $1 is forever being set to
DB And since the
DB function is supposed to be Optional, the user should be able to just type
. db2_env.ksh and get the desired functionality.
And one of the main reasons why the
DB function is Optional is that it takes a long time to run through all the db2 instances and generate the list of DB's. So it's not a function I want to execute every time I run
db2_env.ksh So - you were probably right - you probably did NOT want to know all of that...
Sorry if this is TMI...
#AIX-Forum