04-12-2013
403-009 The specified number is not valid for this command.
Code :
Error Message: dm2_oraver: 9xdm2_oraver2: LT11/w_standard/gold_wh/install/dm2_updatetns.ksh[385]: 11MAR13: 0403-009 The spe
cified number is not valid for this command.
if [385] means the line number in the ksh, it is
((CntNew=Cnt+1)) .
Please let me know the best way to debug and find it out. I am running the built-in ksh, but getting the error.
Code :
#!/bin/ksh
# Mod Date Engineer Change
# 000 07/20/04 AM4598 Created dm2_updatetns.ksh based on updatetns.ksh for new installs.
# 001 01/09/06 EG012557 Modified to default to Oracle 9 path of logic when on Oracle 10
# 002 02/16/06 EG012557 Modify to use : instead of . for chown commands that would run in mode T
# 003 06/23/06 EG012557 Modify to use : instead of . for chown commands that would run in mode A
# Modify listener.ora searching for account for Oracle 10
# Add export UNIX95=Y when on HPUX
# 004 11/17/08 EG012557 Modify to use case-insensitive search when looking for existing TNS entry
# 005 01/29/10 Bg8255 Modifications for Oracle 11.
OnError()
{ # $* = message to write
echo "\n$*\n"
exit 1
}
CheckUser()
{
if [[ $LOGNAME != $1 ]]
then
OnError "Incorrect user $LOGNAME. Login as $1 and try again."
fi
}
GetPort()
{
if [[ `grep -w $NewPort /etc/services | wc -l` -ne 0 ]]
then
if [[ `grep -w $NewPort /etc/services|egrep -e "oracle|tns"|wc -l` -eq 0 ]]
then
OnError "Port Number $NewPort reserved by a non-Oracle process."
fi
else
echo " "
echo "Execute the following commands as the root user to reserve port # $NewPort in the /etc/services file:"
echo " chservices -a -v'oracle_tns' -p'tcp' -n $NewPort -u'# Oracle Listener Port'"
echo " chservices -a -v'oracle_tns' -p'udp' -n $NewPort -u'# Oracle Listener Port'"
echo " "
fi
}
#003
if [[ `uname` = "HP-UX" ]]
then
export UNIX95=Y
fi
#...003
CheckUser oracle
NODENAME=`hostname`
if [[ $NODENAME = "localhost" ]]
then
OnError "Please set the hostname and try again."
fi
#The dm2_oraver variable is set to indicate if it's running for 8i vs. 9i.
#The ORACLE_HOME logical is searched for a "9." to indicate Oracle9, otherwise it defaults to Oracle8 usage.
#The commands in protocol.ora need to be in sqlnet.ora for Oracle9i (dm2_oraver = 9x).
if [[ `echo $ORACLE_HOME|grep -ic '8.'` = 1 ]]
then
dm2_oraver="8x"
else
dm2_oraver="9x"
fi
echo "dm2_oraver:" $dm2_oraver
################################################################################
Usage="
Usage: dm2_updatetns.ksh -?
or dm2_updatetns.ksh -a {alias} -n {node} -p {port} -s {sid} -h {home} -m {A|T}
where:
-a Name for the Sql*Net alias.
-n Node name where the database resides.
-p Port number where the listener is running.
-s Value of Oracle Sid for the Database.
-h Value of Oracle Home for the Database.
-m Mode of operation:
A - Update all .ora files (tnsnames, listener, sqlnet, protocol)
T - Update only the tnsnames.ora file.
"
################################################################################
## Process command line arguments
Alias=""
Node=""
Port=""
OSid=""
OHome=""
Listener=n
while getopts :a:n:p:s:h:m:L:? cmdopts
do
case $cmdopts in
a) Alias="$OPTARG";;
n) Node="$OPTARG";;
p) Port="$OPTARG";;
s) OSid="$OPTARG";;
h) OHome="$OPTARG";;
m) Mode="$OPTARG";;
?) echo "$Usage"
exit 0 ;;
:) echo "no argument for \"-$OPTARG\"" ;;
esac
done
let shiftcnt=$OPTIND-1
shift $shiftcnt
typeset -l Auto
if [[ -z $ORACLE_HOME ]]
then
ORACLE_HOME=$OHome
fi
if [[ -z $TNS_ADMIN ]]
then
if [[ ! -z $ORACLE_HOME ]]
then
TNS_ADMIN=$ORACLE_HOME/network/admin
else
OnError "Error: $TNS_ADMIN is not defined."
fi
fi
if [[ ! -d $TNS_ADMIN ]]
then
OnError "Error: $TNS_ADMIN is not a directory."
fi
if [[ ! -w $TNS_ADMIN ]]
then
OnError "Error: No write permission to $TNS_ADMIN."
fi
dm2_oraver2="GE11"
if [[ `echo $ORACLE_HOME| grep -ic '8.'` > 0 ]]
then
dm2_oraver2='LT11'
fi
if [[ `echo $ORACLE_HOME| grep -ic '9.'` > 0 ]]
then
dm2_oraver2='LT11'
fi
if [[ `echo $ORACLE_HOME| grep -ic '10.'` > 0 ]]
then
dm2_oraver2='LT11'
fi
echo "dm2_oraver2:" $dm2_oraver2
NSF=$TNS_ADMIN/sqlnet.ora
NPF=$TNS_ADMIN/protocol.ora
NLF=$TNS_ADMIN/listener.ora
NTF=$TNS_ADMIN/tnsnames.ora
###########################################################################
### Verify inputs
if [[ -z $Alias ]]
then
OnError "Alias required."
fi
if [[ -z $Node ]]
then
Node=$NODENAME
fi
if [[ $Node = $NODENAME ]]
then
Listener="y"
fi
if [[ -z $Port ]]
then
Port=1521
fi
if [[ -z $OSid ]]
then
OnError "A valid Oracle SID is required in the -s parameter."
fi
if [[ -z $Mode ]]
then
OnError "A valid -m mode (value of A or T) is required."
else
if [[ $Mode != "T" && $Mode != "t" && $Mode != "A" && $Mode != "a" ]]
then
OnError "The mode specified in the -m parameter must be either T or A."
fi
fi
if [[ $Listener = "y" && -z $OHome ]]
then
OHome=$ORACLE_HOME
fi
if [[ $Listener = "y" ]]
then
if [[ -a $NLF ]]
then
for value in `grep -i port $NLF | sed "s/ //g"`
do
value=`echo $value | dd conv=lcase 2>/dev/null`
value=`echo $value | sed "s/(port=/(port=%/g" | cut -f2 -d"%"`
CurPort=`echo $value | awk -F ")" '{print $1}'`
done
if [[ $Port != $CurPort ]]
then
echo " "
echo "Changing the value of Port"
echo " from: $Port"
echo " to: $CurPort"
echo " "
Port=$CurPort
fi
else
NewPort=$Port
if [[ `uname` != "Linux" ]]
then
GetPort
fi
fi
fi
###########################################################################
### $TNS_ADMIN/sqlnet.ora
###########################################################################
#Only process sqlnet.ora and protocol.ora files in Mode = A
if [[ $Mode = "a" || $Mode = "A" ]]
then
if [[ ! -a $NSF ]]
then
echo "################" >> $NSF
echo "# Filename......: sqlnet.ora" >> $NSF
echo "# Node..........: ${NODENAME}.world" >> $NSF
echo "# Date..........: `date`" >> $NSF
echo "################" >> $NSF
echo " Created file - $NSF"
#003 - mod to use oracle:dba
chown oracle:dba $NSF
fi
# Make sure each required entry exists in the sqlnet.ora
if [[ -a $NSF ]]
then
if [[ `grep -ic trace_level_client $NSF` -eq 0 ]]
then
echo " Adding trace_level_client parameter to file $NSF"
echo "trace_level_client = off" >> $NSF
fi
if [[ `grep -ic sqlnet.expire_time $NSF` -eq 0 ]]
then
echo " Adding sqlnet.expire_time parameter to file $NSF"
if [[ $dm2_oraver2 = "GE11" ]]
then
echo "sqlnet.expire_time = 10" >> $NSF
else
echo "sqlnet.expire_time = 0" >> $NSF
fi
fi
if [[ `grep -ic names.default_domain $NSF` -eq 0 ]]
then
echo " Adding names.default_domain parameter to file $NSF"
echo "names.default_domain = world" >> $NSF
fi
#names.default_zone deprecated in 9.2
if [[ `grep -ic name.default_zone $NSF` -eq 0 && $dm2_oraver != "9x" ]]
then
echo " Adding name.default_zone parameter to file $NSF"
echo "name.default_zone = world" >> $NSF
fi
if [[ `grep -ic tcp.nodelay $NSF` -eq 0 && $dm2_oraver = "9x" ]]
then
echo " Adding tcp.nodelay parameter to file $NSF"
echo "# tcp.nodelay moved to sqlnet.ora in Oracle 9x" >> $NSF
echo "tcp.nodelay = yes" >> $NSF
fi
if [[ `grep -ic names.directory_path $NSF` -eq 0 && $dm2_oraver2 = "GE11" ]]
then
echo " Adding names.directory_path parameter to file $NSF"
echo "names.directory_path = (tnsnames)" >> $NSF
fi
if [[ `grep -ic bequeath_detach $NSF` -eq 0 && $dm2_oraver2 = "GE11" ]]
then
echo " Adding bequeath_detach parameter to file $NSF"
echo "bequeath_detach = yes" >> $NSF
fi
if [[ `grep -ic sqlnet.inbound_connect_timeout $NSF` -eq 0 && $dm2_oraver2 = "GE11" ]]
then
echo " Adding sqlnet.inbound_connect_timeout parameter to file $NSF"
echo "sqlnet.inbound_connect_timeout = 0" >> $NSF
fi
if [[ `grep -ic adr_base $NSF` -eq 0 && $dm2_oraver2 = "GE11" ]]
then
echo " Adding adr_base parameter to file $NSF"
echo "adr_base = /u02" >> $NSF
fi
fi
echo ""
###########################################################################
### $TNS_ADMIN/protocol.ora
### Make sure required entries are in protocol.ora
###########################################################################
if [[ ! -a $NPF && $dm2_oraver != "9x" ]]
then
echo "################" >> $NPF
echo "# Filename......: protocol.ora" >> $NPF
echo "# Node..........: ${NODENAME}.world" >> $NPF
echo "# Date..........: `date`" >> $NPF
echo "################" >> $NPF
echo " Created file - $NPF"
#003 - mod to use oracle:dba
chown oracle:dba $NPF
fi
if [[ -a $NPF ]]
then
if [[ `grep -ic tcp.nodelay $NPF` -eq 0 ]]
then
echo " Adding tcp.nodelay parameter to file $NPF"
echo "tcp.nodelay = yes" >> $NPF
fi
fi
fi # end of mode = a or A
###########################################################################
### $TNS_ADMIN/tnsnames.ora
FoundCur="N"
if [[ -a $NTF ]]
then
for CurAlias in `grep -i ".world" $NTF|grep -vi "tcp.world"|cut -f1 -d"."`
do
typeset -u TempCurAlias=$CurAlias
typeset -u TempAlias=$Alias
if [[ $TempCurAlias = $TempAlias ]]
then
FoundCur="Y"
fi
done
fi
#Don't try to readd it to tnsnames.ora if it already exists
if [[ $FoundCur = "N" ]]
then
if [[ ! -a $NTF ]]
then
FileStat="Created"
echo "################" >> $NTF
echo "# Filename......: tnsnames.ora" >> $NTF
echo "# Node..........: ${NODENAME}.world" >> $NTF
echo "# Date..........: `date`" >> $NTF
echo "################" >> $NTF
else
FileStat="Updated"
LastNTF=`ls $NTF.[0-9]* 2>/dev/null | tail -1`
LastNTF=`echo ${LastNTF##*/}`
if [[ -z $LastNTF ]]
then
cp $NTF $NTF.0001
else
Nam=`echo $LastNTF | cut -f1 -d"."`
Ext=`echo $LastNTF | cut -f2 -d"."`
Cnt=`echo $LastNTF | cut -f3 -d"."`
((CntNew=Cnt+1))
while [[ ${#CntNew} -lt 4 ]]
do
CntNew=0$CntNew
done
cp $NTF $TNS_ADMIN/$Nam.$Ext.$CntNew
fi
fi
echo "${Alias}.world =" >>$NTF
echo " (DESCRIPTION =" >>$NTF
#
#community parameter deprecated as of Oracle 9.2
#
if [[ $dm2_oraver = "9x" ]]
then
echo " (ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)" >>$NTF
else
echo " (ADDRESS_LIST=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)" >>$NTF
fi
echo " (Host=${Node})(Port=${Port})))" >>$NTF
echo " (CONNECT_DATA=(SID=${OSid}))" >>$NTF
echo " )" >>$NTF
echo " $FileStat file - $NTF"
#002 - mod to use oracle:dba
chown oracle:dba $NTF*
fi #$FoundCur = "N"
#Only process listener.ora file if input mode = A
if [[ $Mode = "a" || $Mode = "A" ]]
then
###########################################################################
### $TNS_ADMIN/listener.ora
if [[ $Listener = "y" && -a $NLF ]]
then
#003
tmpsid="sid_name=$OSid"
for value in `grep -i sid_name $NLF | sed "s/ //g"`
do
value=`echo $value | dd conv=lcase 2>/dev/null`
if [[ `echo $value | grep -ic ${tmpsid} ` -eq 1 ]]
then
OnError "Oracle_Sid $OSid is already in $NLF"
fi
done
#...003
fi
if [[ $Listener = "y" ]]
then
if [[ -a $NLF ]]
then
# stop the listener before any changes are made
if [[ -a $ORACLE_HOME/bin/lsnrctl ]]
then
if [[ `ps -ef | grep tnslsnr | grep -v grep | wc -l` -ne 0 ]]
then
LsnrName=`ps -fe -o args | grep tnslsnr | grep -v grep | awk '{print $2}'`
echo "*** Stopping listener $LsnrName ..."
$ORACLE_HOME/bin/lsnrctl stop $LsnrName
# The listener start (later) would not work without giving time for the stop to finish
echo "*** Pausing 5 seconds for listener to stop before restarting..."
sleep 5
fi
fi
LastNLF=`ls $NLF.[0-9]* 2>/dev/null | tail -1`
LastNLF=`echo ${LastNLF##*/}`
if [[ -z $LastNLF ]]
then
NextNLF=$NLF.0001
mv $NLF $NextNLF
else
Nam=`echo $LastNLF | cut -f1 -d"."`
Ext=`echo $LastNLF | cut -f2 -d"."`
Cnt=`echo $LastNLF | cut -f3 -d"."`
((CntNew=Cnt+1))
while [[ ${#CntNew} -lt 4 ]]
do
CntNew=0$CntNew
done
NextNLF=$TNS_ADMIN/$Nam.$Ext.$CntNew
mv $NLF $TNS_ADMIN/$Nam.$Ext.$CntNew
fi
cat $NextNLF | sed "s/ /%/g" | while read line
do
echo $line | sed "s/%/ /g" >> $NLF
if [[ `echo $line | grep -i "ADDRESS_LIST" | wc -l` -eq 1 ]]
then
echo " (ADDRESS=(PROTOCOL=IPC)(KEY=${OSid}.world))" >> $NLF
fi
if [[ `echo $line|grep -i "SID_LIST"|grep -vi "LISTENER"|wc -l` -eq 1 ]]
then
echo " (SID_DESC=(SID_NAME=${OSid})(ORACLE_HOME=${OHome}))">> $NLF
fi
done
echo " Updated file - $NLF"
else
echo "################" >> $NLF
echo "# Filename......: listener.ora" >> $NLF
echo "# Node..........: ${NODENAME}.world" >> $NLF
echo "# Date..........: `date`" >> $NLF
echo "################" >> $NLF
echo "STARTUP_WAIT_TIME_LISTENER=0" >> $NLF
echo "CONNECT_TIMEOUT_LISTENER=10" >> $NLF
echo "TRACE_LEVEL_LISTENER=OFF" >> $NLF
echo "LISTENER=" >> $NLF
echo " (ADDRESS_LIST=" >> $NLF
echo " (ADDRESS=(PROTOCOL=IPC)(KEY=${OSid}.world))" >> $NLF
#
#community parameter deprecated as of Oracle 9.2
#
if [[ $dm2_oraver = "9x" ]]
then
echo " (ADDRESS=(PROTOCOL=TCP)(Host=${Node})(Port=${Port}))" >> $NLF
else
echo " (ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=${Node})(Port=${Port}))" >> $NLF
fi
echo " )" >> $NLF
echo "SID_LIST_LISTENER=" >> $NLF
echo " (SID_LIST=" >> $NLF
echo " (SID_DESC=(SID_NAME=${OSid})(ORACLE_HOME=${OHome}))">> $NLF
echo " )" >> $NLF
echo " Created file - $NLF"
fi
#003 - mod to use oracle:dba
chown oracle:dba $NLF*
fi
if [[ $Listener = "y" ]]
then
if [[ -a $ORACLE_HOME/bin/lsnrctl ]]
then
if [[ `ps -ef | grep tnslsnr | grep -v grep | wc -l` -eq 0 ]]
then
echo "*** Starting listener $LsnrName ..."
$ORACLE_HOME/bin/lsnrctl start $LsnrName
fi
fi
fi
fi #input mode = A
chmod 644 $NSF
chmod 644 $NTF
############################################################################
Last edited by zaxxon; 04-12-2013 at 10:41 AM ..
Reason: set that mix of html and php tags to code tags
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Probably a very straight forward question but please be easy on me, I am v. new to UNIX!
A script that I have runs the line
tmp=`pwd -H`
It works fine, but I needed to make a couple of other changes to the script, nowhere near this line but now this line reports:
pwd: A specified flag... (2 Replies)
Discussion started by: Paxton
2 Replies
2. Shell Programming and Scripting
Hi
I am getting few messages when trying to run my script from the following lines in the script
if test
then
// SomeCode
fi
The messages are as follows:
testing.sh: OBLIGOR_GROUP_ID: 0403-012 A test command parameter is not valid.
testing.sh:... (5 Replies)
Discussion started by: skyineyes
5 Replies
3. Shell Programming and Scripting
How to find a string which is entered in command promt is a valid unix command or not?.
Thanks in advance
~Saravana (2 Replies)
Discussion started by: tsaravanan
2 Replies
4. Shell Programming and Scripting
Trying to run the following awk command :
export com.mics.ara.server.tools.sch_reports.Runner.num_threads=`awk -F= '!/^#/ && /com.mics.ara.server.tools.sch_reports.Runner.num_threads/{print $2}' $BKUPDIR/env.properties`
-bash: export:... (6 Replies)
Discussion started by: venhart
6 Replies
5. Shell Programming and Scripting
Hello,
Getting error "A test command parameter is not valid" when trying to run the code below under /sbin/sh
AA = "12:00"
CHK=$(date +"%H:%M")
if
then
print "Yes"
fi
Getting 2 errors:
1) "AA: not found"
2) "Specify a parameter with this command"
Thanks,
IS
Please... (5 Replies)
Discussion started by: schureki
5 Replies
6. Shell Programming and Scripting
Hi,
Am using a if condition to match a pattern but I get the following error..
if
then
echo "The value is $hidType"
return 0
elseif -a ]
echo "The value is $hidType"
return 0
fi
I get the following error
+ echo The value is mode
The value is mode
+
./a2: mode:... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies
7. Shell Programming and Scripting
Heya fellows
Yes, script-tools and TUI are both my 'children', so i cant go anywhere (else) and ask for help/bugfixes as i need to write them myself.
However i do need help to understand error messages at times (or get hints what else might cause them), so here we go:
Since my new computer... (4 Replies)
Discussion started by: sea
4 Replies
8. Shell Programming and Scripting
My question is how would i loop a read command to keep asking the user for input and eventually print the no. of valid invalid inputs after a specified control input typed i.e. (-3). (1 Reply)
Discussion started by: Flowoftruth
1 Replies
9. Shell Programming and Scripting
Hi
I have Unix shell script that invokes PL/SQL procedure.
The batch job when executed terminated with the error message:-unlimited: The specified number is not valid for this command.Please let me know what is the root cause of the issue and how to fix the issue.
Thanks (1 Reply)
Discussion started by: moonkhan1
1 Replies
10. Shell Programming and Scripting
Hi Experts
I would like to ask if there is a way to validate if the variable passed is in this kind of sample format "06-10" or "10-01". It was really a challenge to me on how to start and echnically the "6-10" stands for "June 10" and "10-01" stands as "October 1", overall it needs to have ... (3 Replies)
Discussion started by: ersan-poguita
3 Replies