Why aren't you using getopts? Having consistent methods of parsing options greatly contributes to the ability of users unfamiliar with your code automatically know how to get a quick view of the syntax of your utility (with something like: utility -?), the ability to specify options separately or combined and in any order:
should all produce the same results. And, you should have a built-in help/usage message if an unknown option is found. Instead, your code silently ignores unknown options (leading users to believe that the options they provided were correct when, instead, nothing will be done by your code).
You generally want to set flags while processing options, not run the functions that the options indicate should be run (after you have determined all of hte options that are present).
Your code seems to indicate that the -R option in your utility must always be present. Why have an option if it is always required to be set?
This User Gave Thanks to Don Cragun For This Post:
I'm just not sure where to start looking into this. I want to be able to create switches for my script. Back in the day I'd make my scripts interactive...you know:
echo "what report do you want"
echo "A)boxes with errors"
echo "B)boxes with more than 5 errors"
echo "C)Service groups that have... (3 Replies)
I have wasted one working day writing this scripts.
It compares two folders and make a good tabbed report about their differences.
#!/bin/bash
function DRAW_DEPTH () {
ROUND=$1
while
do
printf %s " "
ROUND=`expr $ROUND - 1`
done
printf %s "|- "
}
function MAIN () {... (9 Replies)
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)
I'm reading about debugging aids in bash and have come across the set command. It says in my little book that an addition to typing
set
you can also use them "on the command line when running a script..." and it lists this in a small table:
set -o option Command Line... (5 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Creating bash script the dd command and its new options (-l -U)
-l options to lowercase contents of file
-U... (2 Replies)
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)
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)
hi guys
we've had nagios spewing false alarm (for the umpteenth time) and finally the customer had enough so they're starting to question nagios. we had the check interval increased from 5 minutes to 2 minutes, but that's just temporary solution. I'm thinking of implementing a script on the... (8 Replies)
I'm trying to run a script that will remotely copy another script to remote host and run copied script to remote server with automatic options-
#! /bin/bash
HOSTNAME="1 2"
for HOST in $HOSTNAME;
do
scp diskFrag.sh login@$HOST:/home/login
sleep 30
ssh login@$HOST... (2 Replies)
Discussion started by: Mannu2525
2 Replies
LEARN ABOUT MOJAVE
time
TIME(1) BSD General Commands Manual TIME(1)NAME
time -- time command execution
SYNOPSIS
time [-lp] utility
DESCRIPTION
The time utility executes and times utility. After the utility finishes, time writes the total time elapsed, the time consumed by system
overhead, and the time used to execute utility to the standard error stream. Times are reported in seconds.
Available options:
-l The contents of the rusage structure are printed.
-p The output is formatted as specified by IEEE Std 1003.2-1992 (``POSIX.2'').
Some shells may provide a builtin time command which is similar or identical to this utility. Consult the builtin(1) manual page.
DIAGNOSTICS
The time utility shall exit with one of the following values:
1-125 An error occurred in the time utility.
126 The utility was found but could not be invoked.
127 The utility could not be found.
Otherwise, the exit status of time shall be that of utility.
SEE ALSO builtin(1), csh(1), getrusage(2)FILES
/usr/include/sys/resource.h
STANDARDS
The time utility conforms to IEEE Std 1003.2-1992 (``POSIX.2'').
BUGS
The granularity of seconds on microprocessors is crude and can result in times being reported for CPU usage which are too large by a second.
BSD June 6, 1993 BSD