Sponsored Content
Top Forums Shell Programming and Scripting Passing options to a bash script Post 302197403 by nua7 on Wednesday 21st of May 2008 01:43:10 AM
Old 05-21-2008
This might also help you..Look out for $1=-g option.


Code:
# # # # # # # # # # # #
#     main section
# # # # # # # # # # # #

  print "script $(basename $0) executing $(date +%Y/%m/%d\ %H:%M:%S) \n"

#
#  only allow this script to be run by the root user
#
  if ! id | grep -q "uid=0(root)" ; then
    print "ERROR:  must be root in order to run this script"
    exit 1
  fi

  if [[ "$PLEX_ROOT" = "/claims/amxw" ]]; then
    if [[ "$NLROOTDIR" != "/claims/amxw" ]]; then
      print "ERROR: NLROOTDIR must be set to /claims/amxw in order to create a plex"
      exit 1
    fi
  fi

  if [[ "$1" = "-g" ]]; then
    shift
    print "You are obviously a plex god and have chosen to skip the approved naming convention.  Please proceed, your eminence"
    print
    mode=GOD
  else
    mode=MORTAL
  fi

  plexname=$1

  if [[ -z $plexname ]]; then
    print "ERROR: plex name isn't specified"
    exit 1
  fi

  if [[ "$mode" = "MORTAL" ]]; then
    if ! print $plexname | grep -q ^plex ; then
      print "ERROR: plex name must begin with 'plex' and be at least 9 characters"
      exit 1
    fi
  fi

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing variable from bash to perl from bash script

Hi All, I need to pass a variable to perl script from bash script, where in perl i am using if condition. Here is the cmd what i am using in perl FROM_DATE="06/05/2008" TO_DATE="07/05/2008" "perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename" filename has... (10 Replies)
Discussion started by: arsidh
10 Replies

2. Shell Programming and Scripting

Passing options into a script

Afternoon all, I have been writing a script to do some selects on a table dependent on what options are selected when the script is run: #!/bin/ksh set -x set -m if then echo "usage: msglog.ksh -da <date and time> -i <interface> -m <msg> -di <direction> -mi <MIR>" exit 1 fi... (3 Replies)
Discussion started by: chris01010
3 Replies

3. Shell Programming and Scripting

bash script to compile multiple .c files with some options

I'm trying to write a bash script and call it "compile" such that running it allows me to compile multiple files with the options "-help," "-backup," and "-clean". I've got the code for the options written, i just can't figure out how to read the input string and then translate that into option... (5 Replies)
Discussion started by: travis.batzer
5 Replies

4. UNIX for Advanced & Expert Users

how to add new options in bash script

what i want to be is that i would like to reinvent new options that have the same functionality as ... -u is the same functionality of conv=ucase and -l have the same functionality as conv=lcase... is there a way that i can put these in my script so that whenever i will typed in command... (12 Replies)
Discussion started by: aphryllyn1
12 Replies

5. Shell Programming and Scripting

Reading command line options from bash script

I have the following code and I am calling it using ./raytrac.bash -u and getting problems. For some reason opt_usage is still 0. opt_usage=0 iarg=0 narg=$# while (($iarg < $narg)) do (( iarg = $iarg + 1 )) arg=$argv usrInputFlag=`echo $arg | awk '/=/ {print 1}; ! /=/... (22 Replies)
Discussion started by: kristinu
22 Replies

6. Shell Programming and Scripting

Passing string from SQL to a BASH script

OS Solaris 10, DB oracle 10g Hello, We currently have a BASH script that runs and moves image files from a remote server to the local db server. A snippet of the code shows that we are picking up all Images that are 'mtime -1' some code... for file in `ssh user@10.200.200.10 'find... (3 Replies)
Discussion started by: JonP
3 Replies

7. Shell Programming and Scripting

Passing arguments to a bash script

Hi, I wanted to pass an argument to a bash script. So that the argument is used inside the awk command inside the bash script. I know the noraml way of passing argument to a bash script as below : sh myScript.sh abc Inside the bash script i can use like this myArg1=$1 wc $myArg But... (8 Replies)
Discussion started by: shree11
8 Replies

8. Shell Programming and Scripting

Passing variable from bash to perl script

Hi All, I need to pass a variable from bash script to perl script and in the perl script i am using those variables in the sql query but its giving error : Use of uninitialized value $ENV{"COUNTRYCD"} in concatenation (.) or string at /GIS_ROOT/custom/tables/DBread_vendor.pl line 50. Can ... (6 Replies)
Discussion started by: NileshJ
6 Replies

9. Web Development

Passing variable from PHP to bash script

I am totally new to PHP and I am trying to create a script that will as a user for a hostname and then use the "hostname" variable to generate a report using REST API. I am able to create the html script and php script to GET the "hostname" but I am having trouble passing the hostname variable... (10 Replies)
Discussion started by: kieranfoley
10 Replies

10. Shell Programming and Scripting

Running options in bash script

Hello UNIX & Linux Forums community! Long time Linux daily user hobbyist, new to shell scripting.... I'm working on a script that does all the "work" in one script, and makes calls to a second script to display info to the user via mostly expanding variables in heredocs. I'm contemplating... (6 Replies)
Discussion started by: Cody Learner
6 Replies
vxmend(1M)																vxmend(1M)

NAME
vxmend - mend simple problems in configuration records SYNOPSIS
vxmend [-fprsvV] [-g diskgroup] [-o useopt] [-U usetype] clear field name ... vxmend [-fprsvV] [-g diskgroup] [-o useopt] [-U usetype] fix how name [arg...] vxmend [-fprsvV] [-g diskgroup] [-o useopt] [-U usetype] off name... vxmend [-fprsvV] [-g diskgroup] [-o useopt] [-U usetype] on name... DESCRIPTION
The vxmend utility performs various Veritas Volume Manager (VxVM) usage-type-specific operations on subdisk, plex, and volume records. The first operand is a keyword that determines the specific operation to perform. The remaining operands specify the configuration objects to which the operation is applied. Each invocation can be applied to only one disk group at a time. Any name operands will be used as record names to determine a default disk group, according to the standard disk group selection rules described in vxintro(1M). A specific disk group can be forced with -g diskgroup. KEYWORDS
clear Clears specified utility fields for each named record in the disk group. An option of -v, -p, or -s specifies that the utility operates only on volumes, plexes, or subdisks, respectively. If a record is a volume, or is associated directly or indirectly with a volume, then the clear operation is performed according to rules used by the usage type appropriate for that volume. The field operand is a comma-separated list of keywords specifying fields to be cleared. Each keyword in the field operand is one of the following: all Clears all clearable utility fields. Normally, this clears all of the persistent and non-persistent utility fields. A usage-type utility may choose a different set of fields, as appropriate. putil Clears all persistent utility fields. putil0, putil1, or putil2 Clears a specific persistent utility field. tutil Clears all non-persistent (temporary) utility fields. tutil0, tutil1, or tutil2 Clears a specific non-persistent utility field. Note: This particular functionality in conjunction with -f and -r flag can be used to recursively clear tutil0 fields in objects undergoing relayout, provided the top most object undergoing relayout is used to initiate it. Usage types may implement additional field keywords. A usage type may also limit the set of clear operations that can be per- formed. fix Changes the state of a volume or plex, named by the name operand, in a manner specified by the how string. The meaning of this operation is entirely usage-type specific. This operation applies only to volumes, or to plexes associated with a volume. Usage type rules appropriate for the volume are used to interpret the command. Additional arguments, after name, are interpreted according to rules defined by the usage type. oem Not used in this release. off Puts the named plexes or volumes into an offline state. This operation can be applied only to volumes, or to plexes associated with a volume. Usage type rules appropriate for the volume are used to perform the operation. on Takes the named plexes or volumes out of the offline state. This operation can be applied only to volumes, or to plexes associ- ated with a volume. Usage type rules appropriate for the volume are used to perform the operation. OPTIONS
-f Forces an operation that VxVM considers potentially dangerous or unnecessary. This enables a limited set of additional opera- tions that would normally not be allowed. Some operations may be disallowed even with this flag. -g diskgroup Specifies the disk group for the operation, either by disk group ID or by disk group name. By default, the disk group is chosen based on the name operands. -o useopt Passes in usage-type-specific options to the operation. -p Requires that name operands name plex records. -r Operates recursively on records associated with the named volume or plex record. Operations applied to a volume will apply to the associated plexes and subdisks. Likewise, operations applied to a plex may be applied to the associated subdisks. -s Requires that name operands name subdisk records. -U usetype Limits the operation to apply to the specified usage type. Attempts to affect volumes with a different usage type will fail. -v Requires that name operands name volume records. -V Displays a list of utilities that would be called from vxmend, along with the arguments that would be passed. The -V performs a preview run so the utilities are not actually called. FSGEN and GEN Usage Types The fsgen and gen usage types provide identical semantics for all operations of the vxmend utility. These usage types provide the follow- ing options as arguments to -o: force Forces an operation that internal consistency checks consider to be questionable. This applies to attempts to use vxmend fix empty to uninitialize a volume that has plexes in the ACTIVE state, and also to attempts to disable the last plex, or the last complete (non-sparse) plex, in a volume. This flag is the same as -f. plex=plexname Requires that any named subdisk record be associated with a plex named plexname. Several plex options can be specified to indi- cate a list of allowed plex names. vol=volume Requires that any named plex or subdisk record be associated, directly or indirectly, with a volume named volume. Several vol options can be specified to indicate a list of allowed volume names. Limitations and extensions for the fsgen and gen usage types consist of the following: clear Keywords supported in the field operands include all standard keywords. In addition, a keyword of the form attnumber can be used to remove locks on a volume for a particular number of concurrent plex attach operations. For example, if the command: vxplex att v1 v1-01 is aborted by pressing the INTERRUPT key (or equivalent) several times (which prevents a clean abort of the operation), you may have to clear the operation with: vxmend clear tutil0 v1-01 vxmend clear att1 v1 vxplex dis v1-01 Interruption of the vxplex att command will display a list of commands to run, which will include the previous list. The number of plexes currently being attached, either directly or as part of a compound operation, is stored in the tutil0 field of the volume record as a string in the form ATTnumber. If the number drops to zero, the tutil0 field is cleared. Some opera- tions on a volume require that the tutil0 field be cleared. Similar to the above example, if an online relayout operation, either started using vxassist or the vxrelayout command is aborted by pressing the the INTERRUPT key (or equivalent) several times (which prevents a clean abort of the operation), you may have to clear the operation with: vxmend -rf clear tutil0 topmost_volume | topmost_plex Interruption of an online relayout operation will display a command similar to above with the appropriate object name to clear the tutil0 field. Online relayout stores a string RELAYOUT in the the tutil0 of all objects subject to relayout. If an interrup- tion caused a cleanup to happen correctly, the tutil0 of all objects used by online relayout will be cleared, else they may or may not be cleared. The vxmend utility of the form mentioned above can be used to clear the tutil0 field. It is important that the object name used in the operation is the topmost object name or any object above the topmost object undergoing relayout. fix The fsgen and gen usage types support the following vxmend fix operations: vxmend fix active plex Sets the state for the named plex to ACTIVE. The state for the volume is set to SYNC. The associated volume must be disabled, and the named plex must be in the STALE state. When starting a volume in the SYNC state, all ACTIVE plexes are enabled and are synchronized to have the same contents using a special read/write-back recovery mode. Any STALE plexes are then recovered by copying data from the ACTIVE plexes. vxmend fix clean plex Sets the state for the named plex to CLEAN. The associated volume must be disabled, the named plex must be in the STALE state, and the volume must have no additional plexes in the CLEAN state. A volume is not startable if one plex is in the CLEAN state and some plexes are in the ACTIVE state. Thus, several vxmend fix operations are normally used in conjunction to set all plexes in a volume to STALE and then to set one plex to CLEAN. A volume start operation will then enable the CLEAN plex and recover the STALE plexes by copying data from the one CLEAN plex. vxmend fix empty volume Sets the named volume and all of its associated plexes to the EMPTY state. The volume can then be re-initialized using vxvol start or any of the vxvol init operations. This operation requires that the volume be disabled. vxmend fix stale plex Sets the state for the named plex to STALE. The associated volume must be disabled, and the named plex must be ACTIVE or CLEAN. This operation names plexes that will be recovered by copying data from other plexes by a vxvol start opera- tion. off The fsgen and gen usage types allow volumes and plexes to be specified as operands to vxmend off. A volume can be named only if -r is used to specify recursion, and is applied to all plexes in the volume. Taking a plex offline disables the plex and sets its state to OFFLINE. Taking the last enabled read-write plex in a volume offline, or the last complete plex (if there are additional sparse plexes), normally fails unless -f is specified. Applying this operation to a volume also disables the volume, and does not require use of -f. If a volume is disabled, then the checks for the last plex or the last complete plex are performed on the set of ACTIVE and CLEAN plexes, rather than on enabled read-write plexes. An offline state for a plex can be cleared with vxmend on. Alternatively, an offline plex can be reattached with vxplex att. on The fsgen and gen usage types allow volumes and plexes to be specified as operands to vxmend on. The vxmend on operation applied to a plex will change the OFFLINE state for a plex to STALE, allowing the plex to be recovered by the next vxvol start or vxvol startall. Applying vxmend on to a volume will change the state for all associated OFFLINE plexes to STALE. RAID-5 Usage Type The raid5 usage type provides the following options as arguments to -o: force Forces an operation that internal consistency checks consider to be questionable. Operations not documented in this section are not supported for the raid5 usage type. In particular, off and on are not supported, but other fsgen and gen operations are supported. In addition, the raid5 usage type also supports the following extension: fix In addition to those supported for the fsgen and gen usage types, the raid5 usage type supports the following vxmend fix opera- tion: vxmend fix unstale subdisk Clears any flags indicating that a subdisk of a RAID-5 plex is invalid. This prevents the data on the subdisk from being recovered when the volume is started. EXIT CODES
The vxmend utility exits with a non-zero status if the attempted operation fails. A non-zero exit code is not a complete indicator of the problems encountered but rather denotes the first condition that prevented further execution of the utility. See vxintro(1M) for a list of standard exit codes. FILES
/usr/lib/vxvm/type/usetype/vxmend The utility that performs vxmend operations for a particular volume usage type. SEE ALSO
vxintro(1M), vxplex(1M), vxvol(1M) VxVM 5.0.31.1 24 Mar 2008 vxmend(1M)
All times are GMT -4. The time now is 09:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy