10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello all,
I have following piece of code which is working fine if executed standalone -
date=$1
set -A max_month 0 31 28 31 30 31 30 31 31 30 31 30 31
eval $(echo $date|sed 's!\(....\)\(..\)\(..\)!year=\1;month=\2;day=\3!')
(( year4=year%4 ))
(( year100=year%100 ))
(( year400=year%400 ))... (7 Replies)
Discussion started by: ektubbe
7 Replies
2. Programming
hi all,
i have made a shell script and it runs until it reaches the if statement, doesn't the ! mean only if the command fails it will echo me that message and then exit
can anyone please help me what is wrong with my code?
many thanks,
rob
#!/bin/bash
echo "is this archive... (10 Replies)
Discussion started by: robertkwild
10 Replies
3. Shell Programming and Scripting
Hi folks,
A really dumb question as I've wasted far too long trying to get this to work.... (on RH bash)
I have an array:
m0='<hello>'
m0='<there>'
m0='<fred>'
v0='<goodbye>'
v0='<again>'
v0='<john>'
in my code I calculate the value of the variable to output and if I echo it, I... (2 Replies)
Discussion started by: say170
2 Replies
4. Programming
Hey so I've written a program and it crashes every time I run it. I tried placing breakpoints to see what was going but to my surprise they do not work! I've placed them anywhere and they do not stop the execution of the program.
In fact if I add code and hit rebuild it doesn't even build that... (1 Reply)
Discussion started by: Cambria
1 Replies
5. UNIX for Dummies Questions & Answers
Hi:
there is a shell script, with the name "foo", located in a bin directory. in the same time, there is an alias "foo='/path/bin/foo' ", just for convenience.
in my home directory, there is a different script with name "foo" too. (a modified version.)
while in my home directory, when I... (3 Replies)
Discussion started by: phil518
3 Replies
6. UNIX for Dummies Questions & Answers
when i started booting linux ,after sometime both the mouse and the keyboard are getting freeze and wont respond(also the system gets hanged and all the process running dont go forward) ,nothing seem to work.
Keeping in mind that it will work after sometime ,i waited for one hour also ,but... (1 Reply)
Discussion started by: sanjay.login
1 Replies
7. Shell Programming and Scripting
Hallo,
I need to test a String (a special ip number-string).
So I want to run that:
ipadress=172.0.0.0
# for debugging:
echo $ipadress | egrep -e '172\.?\.??\.??$'
# the test that doesnt work
if test -z `echo $ipadress | egrep -e '172\.?\.??\.??$'` != ""
then
echo "match"
else... (1 Reply)
Discussion started by: wiseguy
1 Replies
8. UNIX for Advanced & Expert Users
Hi
I tried to put a cron job which pipes the logfile appended to date +%d
but it didnt work .
anyone know how to make this happen
thanks in advance
-prasad (7 Replies)
Discussion started by: p4cldba
7 Replies
9. Shell Programming and Scripting
I am using an array (clmlist01). I have 61 of these and have 4 or more references to each one in a block of code that I do not want to have to hardcode. With that being said, I am creating a varible and going through a for loop to create the actually name of each array. The arrays would end up... (3 Replies)
Discussion started by: dsimpg1
3 Replies
10. Filesystems, Disks and Memory
Alright.
My neighbor kid brings me his iBook and says nothing works. He decided to move the file system to his likeness and that semed to create the problems. Now he doesn't have access rights to his home.
I have run fsck over and over again and I keep getting ** fs modified **
I have also... (0 Replies)
Discussion started by: maxwell
0 Replies
getoptcvt(1) User Commands getoptcvt(1)
NAME
getoptcvt - convert to getopts to parse command options
SYNOPSIS
/usr/lib/getoptcvt [-b] filename
/usr/lib/getoptcvt
DESCRIPTION
/usr/lib/getoptcvt reads the shell script in filename, converts it to use getopts instead of getopt, and writes the results on the standard
output.
getopts is a built-in Bourne shell command used to parse positional parameters and to check for valid options. See sh(1). It supports all
applicable rules of the command syntax standard (see Rules 3-10, intro(1)). It should be used in place of the getopt command. (See the
NOTES section below.) The syntax for the shell's built-in getopts command is:
getopts optstring name [ argument...]
optstring must contain the option letters the command using getopts will recognize; if a letter is followed by a colon (:), the option is
expected to have an argument, or group of arguments, which must be separated from it by white space.
Each time it is invoked, getopts places the next option in the shell variable name and the index of the next argument to be processed in
the shell variable OPTIND. Whenever the shell or a shell script is invoked, OPTIND is initialized to 1.
When an option requires an option-argument, getopts places it in the shell variable OPTARG.
If an illegal option is encountered, ? will be placed in name.
When the end of options is encountered, getopts exits with a non-zero exit status. The special option -- may be used to delimit the end of
the options.
By default, getopts parses the positional parameters. If extra arguments (argument ...) are given on the getopts command line, getopts
parses them instead.
So that all new commands will adhere to the command syntax standard described in intro(1), they should use getopts or getopt to parse posi-
tional parameters and check for options that are valid for that command (see the NOTES section below).
OPTIONS
The following option is supported:
-b Makes the converted script portable to earlier releases of the UNIX system. /usr/lib/getoptcvt modifies the shell script in file-
name so that when the resulting shell script is executed, it determines at run time whether to invoke getopts or getopt.
EXAMPLES
Example 1: Processing the arguments for a command
The following fragment of a shell program shows how one might process the arguments for a command that can take the options -a or -b, as
well as the option -o, which requires an option-argument:
while getopts abo: c
do
case $c in
a | b) FLAG=$c;;
o) OARG=$OPTARG;;
?) echo $USAGE
exit 2;;
esac
done
shift `expr $OPTIND - 1`
Example 2: Equivalent code expressions
This code accepts any of the following as equivalent:
cmd -a -b -o "xxx z yy" filename
cmd -a -b -o "xxx z yy" -filename
cmd -ab -o xxx,z,yy filename
cmd -ab -o "xxx z yy" filename
cmd -o xxx,z,yy b a filename
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of getopts: LC_CTYPE, LC_MESSAGES, and
NLSPATH.
OPTIND This variable is used by getoptcvt as the index of the next argument to be processed.
OPTARG This variable is used by getoptcvt to store the argument if an option is using arguments.
EXIT STATUS
The following exit values are returned:
0 An option, specified or unspecified by optstring, was found.
>0 The end of options was encountered or an error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |enabled |
+-----------------------------+-----------------------------+
SEE ALSO
intro(1), getopts(1), sh(1), shell_builtins(1), getopt(3C), attributes(5)
DIAGNOSTICS
getopts prints an error message on the standard error when it encounters an option letter not included in optstring.
NOTES
Although the following command syntax rule (see intro(1)) relaxations are permitted under the current implementation, they should not be
used because they may not be supported in future releases of the system. As in the EXAMPLES section above, -a and -b are options, and the
option -o requires an option-argument. The following example violates Rule 5: options with option-arguments must not be grouped with
other options:
example% cmd -aboxxx filename
The following example violates Rule 6: there must be white space after an option that takes an option-argument:
example% cmd -ab oxxx filename
Changing the value of the shell variable OPTIND or parsing different sets of arguments may lead to unexpected results.
SunOS 5.10 7 Jan 2000 getoptcvt(1)