Sponsored Content
Top Forums Shell Programming and Scripting Command line not getting assigned in script. Post 302341077 by Veenak15 on Wednesday 5th of August 2009 03:52:23 AM
Old 08-05-2009
Command line not getting assigned in script.

I am running the following script and passing the following command line arguments :

DBCheckSum_control CA_SITE CA_SITE

Can someone please tell me, why my command line args are not being accepted and assigned to variable "TABLE_NAME'' and "ACTION_TYPE"??
Code:
usage()
{
print "Usage: ${0} { inc_non_primary }"
print "Usage: ${table_name} ${ c}"
}

option_count=${#}

. /opt/projects/gsd/scripts/functions gsd > /dev/null 2>&1



 
 if [ "${option_count}" -eq 1 ]
 then
 	ACTION_TYPE="${1}"
 fi	 
 
 if [ "${option_count}" -eq 2 ]
 then
 	TABLE_NAME=${1}
 	ACTION_TYPE=${2}  			  
 	
 	echo "${ACTION_TYPE}" 
	echo "${TABLE_NAME}"
 fi	
 
 if [ "${option_count}" -gt 2 ]
 then
      usage
      exit 1
   fi

APPLNAME="DBCheckSum"
LOGFILE="${NIGHTLY_LOG_DIR}/${APPLNAME}.${DATETIME_STAMP}.log"
ERROR_LOGFILE="${NIGHTLY_LOG_DIR}/${APPLNAME}.${DATETIME_STAMP}.err"

if [ "${CURR_USER}" != "srvcdesk" ]; then
        log_msg "You must be srvcdesk to execute this script, ABORTING!"
        exit 5
fi


case "${option_count}" in
  1)	java -Xms256m -Xmx1536m "${APPLNAME}" "${ACTION_TYPE}" > "${LOGFILE}" 2> "${ERROR_LOGFILE}"
  	;;
  2)    java -Xms256m -Xmx1536m "${APPLNAME}" "${TABLE_NAME}" "${ACTION_TYPE}" > "${LOGFILE}" 2> "${ERROR_LOGFILE}"
  	;;
  *)	usage;
	exit 1;;
esac



---------- Post updated at 01:22 PM ---------- Previous update was at 01:21 PM ----------

Sorry passing Command line args as :

DBCheckSum_control CA_SITE inc_non_primary
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Return code of command assigned to variable

How do I evaluate the result of a command assigned to a variable?? Example: var1=`cmd` rc=$? rc will be the result of the assignment rather than cmd since it executes after. How do I evaluate the result of the command itself? Cheers..:confused: (2 Replies)
Discussion started by: browndr
2 Replies

2. Solaris

Command to list all the VIP addresses assigned to Solaris server

Hello All, I want to list all the VIP addresses assigned to Solaris server. whats the command we have use on solaris for this? Please help Thanks!! Weblogic Consultant (1 Reply)
Discussion started by: weblogicsupport
1 Replies

3. Shell Programming and Scripting

Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone, when executing this command in unix: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csvIt works fine, but running this command in a shell script gives an error saying that there's a syntax error. here is content of my script: tdbsrvr$ vi hc.sh "hc.sh" 22 lines, 509... (4 Replies)
Discussion started by: 4dirk1
4 Replies

4. Shell Programming and Scripting

perl script command line option driven script

could someone show me a sample command line option driven script? i want to see an easy way to write one and how i can execute it using command line options such as typing in read.pl -i <id> -c <cmds> -s <start> -e <end> would read out all the commands run by ID . from start time to... (7 Replies)
Discussion started by: kpddong
7 Replies

5. Solaris

Command files when the output is assigned to a variable

Hi, i'm posting this in the Solaris forum although maybe it should be better in the General unix forum, I'm formatting an output witht he following command: crontab -l | grep GBOUAT8 | grep UTP | grep -i stop | sed 's/\\//' 08 2 * * 2-6 /apps/sum_glob/gbo_uat/sparse/bin/dmg_cronlaunch -ENVI... (2 Replies)
Discussion started by: Cvg
2 Replies

6. Shell Programming and Scripting

Command executes on the command line but not from script

Hello guys, I have the following commands : Command 1: sudo find "../bundlepool" -name "merchandising2.html" -print0 |xargs -0 -I {} cp "rebranding/merchandising2.html" {} Command 2: find "../bundlepool" -name "merchandising2.html" -exec cp rebranding/merchandising2.html {} \; Command 3: ... (2 Replies)
Discussion started by: ihabo01
2 Replies

7. Shell Programming and Scripting

Syntax error piping to bc on command line - works when assigned to var

I have a script which outputs some timing data a line at a time. There are approx. 10 lines echoed, each line looks something like this: 0.741 http://checkip.dyndns.org 94.170.119.226Since I needed to add all the values in the first column, I piped the output to grep, matching and printing the... (7 Replies)
Discussion started by: gencon
7 Replies

8. Shell Programming and Scripting

SH script, variable built command fails, but works at command line

I am working with a sh script on a solaris 9 zone (sol 10 host) that grabs information to build the configuration command line. the variables Build64, SSLopt, CONFIGopt, and CC are populated in the script. the script includes CC=`which gcc` CONFIGopt=' --prefix=/ --exec-prefix=/usr... (8 Replies)
Discussion started by: oly_r
8 Replies

9. Shell Programming and Scripting

Works on command line but not in script

OSX 10.9 I am building a script that evaluates the difference between 2 files. Here is a command that does not work transparently. Running this command in Terminal yields great results; however when I put that line in a .sh script, I get the errors shown below. Am I doing something silly? ... (1 Reply)
Discussion started by: sudo
1 Replies

10. Shell Programming and Scripting

Command assigned to a variable is failed or not having any data - error

Hi, My command is getting stuck while running it. observed that the grep command doesn't returned any data ($? was 1) and it failed. This command is assigned into the variable and used in other command as script progresses. To continue the script output, i have to press ^C twice and script... (2 Replies)
Discussion started by: abhii
2 Replies
GETFLAGS(8)						      System Manager's Manual						       GETFLAGS(8)

NAME
getflags, usage - command-line parsing for shell scripts SYNOPSIS
getflags $* usage [ progname ] DESCRIPTION
Getflags parses the options in its command-line arguments according to the environment variable $flagfmt. This variable should be a list of comma-separated options. Each option can be a single letter, indicating that it does not take arguments, or a letter followed by the space-separated names of its arguments. Getflags prints an rc(1) script on standard output which initializes the environment variable $flagx for every option mentioned in $flagfmt. If the option is not present on the command-line, the script sets that option's flag vari- able to an empty list. Otherwise, the script sets that option's flag variable with a list containing the option's arguments or, if the option takes no arguments, with the string 1. The script also sets the variable $* to the list of arguments following the options. The final line in the script sets the $status variable, to the empty string on success and to the string usage when there is an error parsing the command line. Usage prints a usage message to standard error. It creates the message using $flagfmt, as described above, $args, which should contain the string to be printed explaining non-option arguments, and $0, the program name (see rc(1)). If run under sh(1), which does not set $0, the program name must be given explicitly on the command line. EXAMPLE
Parse the arguments for leak(1): flagfmt='b,s,f binary,r res,x width' args='name | pid list' if(! ifs=() eval `{getflags $*} || ~ $#* 0){ usage exit usage } SOURCE
/src/cmd/getflags.c /src/cmd/usage.c SEE ALSO
arg(3) GETFLAGS(8)
All times are GMT -4. The time now is 08:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy