Sponsored Content
Top Forums Shell Programming and Scripting Setting Verbosity Option of Script Post 302602387 by kristinu on Monday 27th of February 2012 12:01:57 PM
Old 02-27-2012
Setting Verbosity Option of Script

I have a script and I want the verbosity option to work in the following way:

User can either set quiet (no verbosity), use default verbosity level (when doing -v), or set a level value (when doing -v=2 or --vrbLevel=2).

I am making some more progress on this and am thinking of this idea.
Code:
if ($opt_quiet == 1) then
  set opt_verbose = 0                   # No verbosity allowed
  set vrbLevel = 0                        # Set to verbosity level 0 (quiet)
else if () then
  set                                             # Set to user level
else
  set vrbLevel = Def_vrbLevel    # Set default verbosity level
endif

The problem I am having is when I try to set the user value.

Code:
set ierr = 0
set iarg = 0
set opt_verbose = 0
set opt_usage = 0

set Def_vrbLevel = 1

set arg_fullNamesLst = ""
set narg = $#argv
while ($iarg < $narg)

  MATH iarg = $iarg + 1

  set arg = $argv[$iarg]
  set opt = `echo $arg | awk 'BEGIN {FS="="} {print $1}' | tr '[:lower:]' '[:upper:]'`
  set par = `echo $arg | awk 'BEGIN {FS="="} {print $2}'`

  switch ($opt)

    case "-V":
    case "--VRB-LEVEL":
      set arg_vrbLevel = $par
      set opt_verbose = 1
      breaksw

    case "-Q":
    case "--QUIET":
      set opt_quiet = 0
      breaksw

    default:
      set arg_fullNamesLst = "$arg_fullNamesLst $arg"
      breaksw

  endsw

end   # while

if ($opt_quiet == 1) then
  set opt_verbose = 0
  set vrbLevel = 0
else if () then
  set vrbLevel = arg_vrbLevel
else
  set vrbLevel = $Def_vrbLevel
endif

if (($verbose == 1) && ($vrbLevel >=3)) then
  echo "Some information"
endif


Last edited by kristinu; 02-27-2012 at 01:12 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies

2. Shell Programming and Scripting

\n option in script

I have a series of around 20 files as my program output. The final line of my script gets the no of files and the file list for the present day. The no of files shoudl be printed first and the files for today must be printed in the next line. Ialso understood that echo -e must be used for with \n.... (4 Replies)
Discussion started by: venkidhadha
4 Replies

3. Shell Programming and Scripting

Need help with script option

Hi, So my script reads $1 on the command line. example: SCRIPT_NAME 1111 In my script I use a nawk statement to grab $1 but I also need it to read $1 from the variable (1111 from command line in the example) nawk -F, '($1~1111)' *.$date.* What can I do so that this nawk statement... (2 Replies)
Discussion started by: llsmr777
2 Replies

4. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

5. 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

6. Programming

Reading command line arguments and setting up values if option not provided

I have a C++ program. I read command line arguments, but if the value is not supplied, I default or make a calculation. Let's say I set it to a default value. I can code this in several ways. Here I show three ways. What would be the best way for maintaining this code? The program will get very... (2 Replies)
Discussion started by: kristinu
2 Replies

7. Shell Programming and Scripting

Call one script option to other in shell script

HI Guys, My Script abc.sh 1) Checks 2) CA Scipt 3) CIA Script 0) Exit Enter Choice : Now if i select choice 2 then after finshed choice 2 wait for 40 min and run choice 3 what i can write in CA Scipt option: if then My Code : ... (3 Replies)
Discussion started by: pareshkp
3 Replies

8. Shell Programming and Scripting

Script to call a menu script and redirect each option to a text file

Hello, I want to design a script that will call an existing menu script and select options one by one and redirict the out put to a file. For example;- In the script MENU.sh there are 10 options i want to design a script MENU2.sh that will select option 2 3 4 6 7 10 and redirict the output... (4 Replies)
Discussion started by: spradha
4 Replies

9. Red Hat

Grub.conf kernel field boot messages verbosity configuration

I am trying to understand what are the differences of boot messages verbosity levels for the kernel field in grub.conf From my research, there appear to be three levels: quiet verbose debug I have also found documents that specify removing quiet from the kernel field. If this is done, is... (1 Reply)
Discussion started by: thaebich
1 Replies
INFNAN(3M)																INFNAN(3M)

NAME
infnan - signals invalid floating-point operations on a VAX (temporary) SYNOPSIS
#include <math.h> double infnan(iarg) int iarg; DESCRIPTION
At some time in the future, some of the useful properties of the Infinities and NaNs in the IEEE standard 754 for Binary Floating-Point Arithmetic will be simulated in UNIX on the DEC VAX by using its Reserved Operands. Meanwhile, the Invalid, Overflow and Divide-by-Zero exceptions of the IEEE standard are being approximated on a VAX by calls to a procedure infnan in appropriate places in libm. When better exception-handling is implemented in UNIX, only infnan among the codes in libm will have to be changed. And users of libm can design their own infnan now to insulate themselves from future changes. Whenever an elementary function code in libm has to simulate one of the aforementioned IEEE exceptions, it calls infnan(iarg) with an appropriate value of iarg. Then a reserved operand fault stops computation. But infnan could be replaced by a function with the same name that returns some plausible value, assigns an apt value to the global variable errno, and allows computation to resume. Alternatively, the Reserved Operand Fault Handler could be changed to respond by returning that plausible value, etc. instead of aborting. In the table below, the first two columns show various exceptions signaled by the IEEE standard, and the default result it prescribes. The third column shows what value is given to iarg by functions in libm when they invoke infnan(iarg) under analogous circumstances on a VAX. Currently infnan stops computation under all those circumstances. The last two columns offer an alternative; they suggest a setting for errno and a value for a revised infnan to return. And a C program to implement that suggestion follows. IEEE IEEE Signal Default iarg errno infnan __________________________________________________ Invalid NaN EDOM EDOM 0 Overflow +-Infinity ERANGE ERANGEHUGE Div-by-0 +-Infinity +-ERANGE ERANGE or EDOM+-HUGE (HUGE = 1.7e38 ... nearly 2.0**127) ALTERNATIVE infnan: #include <math.h> #include <errno.h> extern int errno ; double infnan(iarg) int iarg ; { switch(iarg) { case ERANGE: errno = ERANGE; return(HUGE); case -ERANGE: errno = EDOM; return(-HUGE); default: errno = EDOM; return(0); } } SEE ALSO
math(3M), intro(2), signal(3). ERANGE and EDOM are defined in <errno.h>. See intro(2) for explanation of EDOM and ERANGE. 4.3 Berkeley Distribution May 27, 1986 INFNAN(3M)
All times are GMT -4. The time now is 05:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy