Sponsored Content
Full Discussion: ksh and getopts
Top Forums Shell Programming and Scripting ksh and getopts Post 302257562 by garskoci on Wednesday 12th of November 2008 01:34:23 PM
Old 11-12-2008
FYI - Resolved. I just counted the number of v's that were being passed into the script.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

getopts

I have a script which fires a command based on certain parameters. I am posting the code below.. The options needs be given such that -u option goes along with -d and -s, -f goes with -d and -t goes with -s and -d. 1) How do I ensure that user misses any of the option then he should be... (5 Replies)
Discussion started by: yerra
5 Replies

2. Shell Programming and Scripting

ksh: can you use getopts in a function?

I wrote a script that uses getopts and it works fine. However, I would like to put the function in that script in a startup file (.kshrc or .profile). I took the "main" portion of the script and made it a function in the startup script. I source the startup script but it doesn't seem to parse... (4 Replies)
Discussion started by: lyonsd
4 Replies

3. Shell Programming and Scripting

getopts help

Hi i have part of the scripts below ,getopt for -h or ? not working for me. can anybody tell me if this sytax right or wrong. #!/usr/bin/ksh program=$(basename $0) ##################################################################################### function usageerr { RC=1 ... (3 Replies)
Discussion started by: GrepMe
3 Replies

4. Shell Programming and Scripting

Using getopts

I am having some trouble/questions with getopts that I can't find any solid info on with google I need it to parse things of the syntax of: -r # # # -f -c with as many repeats as possible, and it should catch erroneous commands also, but continue going... my first question is, -r... (3 Replies)
Discussion started by: TurboArkhan
3 Replies

5. Shell Programming and Scripting

ksh function getopts get leading underscore unless preceded by hyphen

If I call my function with grouped options: "logm -TDIWEFO 'message' ", then only the "T" gets parsed correctly. The subsequent values returned have underscores prefixed to the value: "_D", "_I", etc. If I "logm -T -DIWEFO 'message' ", the "T" and the "D" are OK, but "I" through "O" get the... (2 Replies)
Discussion started by: kchriste
2 Replies

6. Shell Programming and Scripting

Help on getopts in ksh

I am trying to make a Shell Script in KSH on Linux box and Solaris box which takes few arguments... with long options using getopts (not getopt). I have my sample code... at the end I will say my requirement... Please help me folks... $ cat dummy #!/bin/bash # Argument = -t test -r server... (6 Replies)
Discussion started by: explorer007
6 Replies

7. Shell Programming and Scripting

ksh "getopts" -- Unsetting an Option

I use the "getopts" ksh built-in to handle command-line options, and I'm looking for a clean/standard way to "unset" an option on the command line. I don't know if this is a technical question about getopts or more of a style/standards question. Anyway, I understand that getopts processes its... (4 Replies)
Discussion started by: Matt Miller
4 Replies

8. Shell Programming and Scripting

Getopts in the subshell of ksh

Hi, the getopts doesnt seem to be working in the subshell of the ksh. when I echo $@ and $* from the subshell it shows nothing. even when I am capturing the parameters from the outer shell and passing while invoking the file then I am still not getting it properly. the below code is in the... (9 Replies)
Discussion started by: hitmansilentass
9 Replies

9. Shell Programming and Scripting

Using getopts in ksh

I want to use getopts in ksh scripting to obtain multiple values currently im using while getopts vt: opt do case "$opt" in -v) vn=$OPTARG;; -t) tn="$OPTARG";; ;; # terminate while loop esac done however variables vn tn dont store any... (3 Replies)
Discussion started by: E.sh
3 Replies

10. Shell Programming and Scripting

ksh - default value for getopts option's argument

Hello everyone, I need help in understanding the default value for getopts option's argument in ksh. I've written a short test script: #!/bin/ksh usage(){ printf "Usage: -v and -m are mandatory\n\n" } while getopts ":v#m:" opt; do case $opt in v) version="$OPTARG";; ... (1 Reply)
Discussion started by: da1
1 Replies
cache_create(3) 					   BSD Library Functions Manual 					   cache_create(3)

NAME
cache_create -- Creates an in memory cache SYNOPSIS
#include <cache.h> int cache_create(const char *name, cache_attributes_t *attrs, cache_t **cache_out); int cache_destroy(cache_t *cache); DESCRIPTION
cache_create() Creates a cache using attributes attrs (see below) and name name and if successful stores it in cache_out. name is a NULL- terminated cstring in reverse-DNS form (e.g. "com.mycompany.imagecache") and is used for debugging and performance tools. It must not be NULL. cache_destroy() Removes all unreferenced values in cache and deallocates it. CACHE ATTRIBUTES
Cache attributes are callbacks passed to cache_create() to support different types of keys and values and to configure cache behavior. The cache framework provides preexisting cache_callbacks(3) functions that can be used for these callbacks to support common key and value types typedef struct cache_attributes_s { uint32_t version; cache_key_hash_cb_t key_hash_cb; cache_key_is_equal_cb_t key_is_equal_cb; cache_key_retain_cb_t key_retain_cb; cache_release_cb_t key_release_cb; cache_release_cb_t value_release_cb; cache_value_make_nonpurgeable_cb_t value_make_nonpurgeable_cb; cache_value_make_purgeable_cb_t value_make_purgeable_cb; void *user_data; cache_value_retain_cb_t value_retain_cb; } cache_attributes_t; #define CACHE_ATTRIBUTES_VERSION_2 2 key_hash_cb Calculates a hash value using key key_is_equal_cb Determines if two keys are equal key_retain_cb Called when a key is added to a cache using cache_set_and_retain() to allow key to be copied, or retained if it is a reference-counted object. key_release_cb Called when a key is removed or evicted from a cache to allow the key to be deallocated, or released if it is a reference-counted object. value_retain_cb Called when a value is added to a cache using cache_set_and_retain() to allow value to be retained if it is a reference-counted object. value_release_cb Called when a value is removed or evicted from a cache to allow the key to be deallocated, or released if it is a reference-counted object. value_make_nonpurgeable_cb Called when a value is referenced using cache_get_and_retain() to allow it to be made nonpurgeable or uncom- pressed. value_make_purgeable_cb Called when a value is unreferenced to allow it to be made purgeable or compressed. version Attributes version number used for binary compatibility. user_data This value will be passed to all other callbacks for this cache. May be NULL. RETURN VALUES
All functions return 0 for success and non-zero for failure. EXAMPLE
The following example uses pre-existing cache_callbacks(3) to create a cache with cstring keys and malloc(3) allocated values. The #include <cache.h> #include <cache_callbcaks.h> cache_t *im_cache; cache_attributes_t attrs = { .version = CACHE_ATTRIBUTES_VERSION_2, .key_hash_cb = cache_key_hash_cb_cstring, .key_is_equal_cb = cache_key_is_equal_cb_cstring, .key_retain_cb = my_copy_string, .key_release_cb = cache_release_cb_free, .value_release_cb = cache_release_cb_free, }; cache_create("com.acme.im_cache", &attrs, &im_cache); SEE ALSO
cache(3) cache_set_and_retain(3) cache_callbacks(3) Darwin May 7, 2009 Darwin
All times are GMT -4. The time now is 02:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy