9 More Discussions You Might Find Interesting
1. Programming
while ((numRead = read(inputFd, buf, BUF_SIZE)) > 0)
if (write(outputFd, buf, numRead) != numRead)
fatal("couldn't write whole buffer");
if (numRead == -1)
errExit("read");
if (close(inputFd) == -1)
errExit("close input");
if (close(outputFd) == -1)
errExit("close output");
... (1 Reply)
Discussion started by: fwrlfo
1 Replies
2. Shell Programming and Scripting
Hello -- I am trying to learn to do a little sed and awk scripting to search for text and numbers in text files (text processing/manipulation). My professor gave me a piece of uncommented code and I am very unfamiliar w/ the language. Can someone help me with comments so I can understand what is... (2 Replies)
Discussion started by: smithan05
2 Replies
3. Shell Programming and Scripting
I am looking for suggestions on how I could possibly optimized that piece of code where most of the time is spend on this script. In a nutshell this is a script that creates an xml file(s) based on certain criteria that will be used by a movie jukebox.
Example of data:
$SORTEDTMP= it is a... (16 Replies)
Discussion started by: snappy46
16 Replies
4. Shell Programming and Scripting
Hello All,
I have 2 questions,
1) I am on Unix Sun Solaris korn shell, in my shell scripts i am using
#!/bin/sh Instead of #!/bin/ksh, though it is still working is this correct way of doing and also I am saving the shell script file as abc.sh instead of abc.ksh, please let me know the best... (1 Reply)
Discussion started by: Ariean
1 Replies
5. Shell Programming and Scripting
hi fndz.
Can you please help me with the code if I call a stored procedure from my shell script and stored procedure returns a cursor,
cursor output should be saved to a file (3 Replies)
Discussion started by: enigma_83
3 Replies
6. UNIX for Dummies Questions & Answers
A very n00b question: After compiling and installing software, where does the original source code reside? I'd like to study the source code of some of the ports I've installed. Thanks! :D (1 Reply)
Discussion started by: Aaron Van
1 Replies
7. Shell Programming and Scripting
Started writing my code.
my read input is not even asking nor working?
And I get a EOF script error.
echo "1) aragorn.domain.net"
echo "2) marvel.domain.net"
echo "3) athena.domain.net"
echo "4) gandalf.domain.net"
echo "5) griffin.domain.net"
echo "What server would you like... (4 Replies)
Discussion started by: chrchcol
4 Replies
8. Shell Programming and Scripting
Hi All,
I am trying to understand and change some code written by some programmer a while ago. There are following three lines of code that I am unable to grasp. Could anybody please help me understand it?
1) cd - > /dev/null
2) fname=`basename "$1"` where $1 = /dirA/dirB/a.txt
... (3 Replies)
Discussion started by: Vikas Sood
3 Replies
9. Shell Programming and Scripting
I am getting an error "ftpNotes.sh: syntax error at line 8 : `<<' unmatched"
#!/bin/ksh
PATH=/usr/sbin/:/usr/bin:/usr/ucb:/etc:/usr/local/bin:.
cd $HOME
if ;then
if ; then
echo 'DSC file already ftp to epm server'
else
ftp -n epmdev00 <<SCRIPT... (1 Reply)
Discussion started by: sibghat
1 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)