Sponsored Content
Top Forums Shell Programming and Scripting Trouble setting up flag ( getopt) for my script Post 302677299 by upenmishra on Thursday 26th of July 2012 01:14:44 AM
Old 07-26-2012
added to my question

Last edited by upenmishra; 07-26-2012 at 02:50 AM..
 

9 More Discussions You Might Find Interesting

1. IP Networking

Trouble setting up a static IP on NetGear DGN1000

I have been trying to setup a static ip, however everytime I do so my internet disconnects and won't connect untill I switch back to dynamic. My router is a NetGear DGN1000 and I'm using it wired. Could anyone help? (0 Replies)
Discussion started by: zomigosh
0 Replies

2. Ubuntu

Trouble setting up Java classpath

Saw an error while setting up an application called i2phex: # ./run.sh java.lang.RuntimeException: Failed to initialize phex.net.repres.i2p.I2PPresentationManager at phex.common.ManagerController.initializeManagers(ManagerController.java:78) at phex.Main.main(Main.java:161)After... (0 Replies)
Discussion started by: Israel213
0 Replies

3. UNIX for Dummies Questions & Answers

Trouble Setting Up Sun Ultra 10 - Displaying Garbage

Hello there, I am new to this forum as well as to the UNIX world. Recently graduated with a degree in Computing and just started learning UNIX & bought 3 Sun Ultra 10 Servers. I was trying to set the Servers up so I can use them; the Servers don't have a VGA card. My laptop, which I would be... (6 Replies)
Discussion started by: frhan2u
6 Replies

4. Shell Programming and Scripting

setting up a flag inside awk

Hi unix gurus.... i need to set a flag inside awk. i tried many methods for that but couldn't succeed :( like echo "flag= " $flag echo "flag= " ${flag} and so...but not able to show the flag. help me out. i'm using a if condition inside awk... help me out with correct syntax to set a... (7 Replies)
Discussion started by: sukhdip
7 Replies

5. UNIX for Dummies Questions & Answers

Trouble setting up a shared folder

I'm trying to set up a folder in my home directory that will be shared with another user but for some reason it is not working this is what I've done, I have tried two different ways using ACL's and chown/chgrp etc I set up a group called say: sharedgroup and added both my user (john) and fred... (3 Replies)
Discussion started by: 14952john
3 Replies

6. Linux

Trouble setting up basic user authentication on apache2 web server

Hey guys! So I decided to set up some basic user authentication on my apache2 server, and I am running into some problems. I followed the documentation provided by apache on their website, but I cant create the password file for some reason. I did a little trouble shooting myself, and found... (40 Replies)
Discussion started by: LinuxIntern445
40 Replies

7. Proxy Server

Samba on AIX, issues setting read-only flag on files?

Hello, I am having issues setting the "read-only" flag via Windows Explorer on my AIX Samba share... I have on my AIX 7.1 system installed Samba 3.6.24 and configured, joined to our Windows domain successfully. The samba binaries I got from perzl.org/aix In my smb.conf I have... ... (1 Reply)
Discussion started by: c3rb3rus
1 Replies

8. Shell Programming and Scripting

Trouble with setting a variable with vastool

Hi I have this command that when put on the command line it returns the output the way I want it. /opt/quest/bin/vastool list -a groups | grep testdev_li | grep dev | awk -F"" 'NF>2{print $2}' | cut -c2- | tr '\n' '|' The output of this is ... (2 Replies)
Discussion started by: ajetangay
2 Replies

9. Shell Programming and Scripting

Getopt eval set parameters not happening when the script is called through an application!

Hi, There is an Informatica tool through which unix scripts can be called. Now the requirement in my project is that a parent script calls a child script but this parent script has to be called through the Informatica tool. In Parent script I'm using TEMP=`getopt -o x:y: -l area:,volume:... (1 Reply)
Discussion started by: Panna
1 Replies
GETOPT(1)						    BSD General Commands Manual 						 GETOPT(1)

NAME
getopt -- parse command options SYNOPSIS
args=`getopt optstring $*` ; errcode=$?; set -- $args DESCRIPTION
The getopt utility is used to break up options in command lines for easy parsing by shell procedures, and to check for legal options. Optstring is a string of recognized option letters (see getopt(3)); if a letter is followed by a colon, the option is expected to have an argument which may or may not be separated from it by white space. The special option '--' is used to delimit the end of the options. The getopt utility will place '--' in the arguments at the end of the options, or recognize it if used explicitly. The shell arguments ($1 $2 ...) are reset so that each option is preceded by a '-' and in its own shell argument; each option argument is also in its own shell argu- ment. EXAMPLES
The following code fragment shows how one might process the arguments for a command that can take the options -a and -b, and the option -o, which requires an argument. args=`getopt abo: $*` # you should not use `getopt abo: "$@"` since that would parse # the arguments differently from what the set command below does. if [ $? != 0 ] then echo 'Usage: ...' exit 2 fi set -- $args # You cannot use the set command with a backquoted getopt directly, # since the exit code from getopt would be shadowed by those of set, # which is zero by definition. for i do case "$i" in -a|-b) echo flag $i set; sflags="${i#-}$sflags"; shift;; -o) echo oarg is "'"$2"'"; oarg="$2"; shift; shift;; --) shift; break;; esac done echo single-char flags: "'"$sflags"'" echo oarg is "'"$oarg"'" This code will accept any of the following as equivalent: cmd -aoarg file file cmd -a -o arg file file cmd -oarg -a file file cmd -a -oarg -- file file SEE ALSO
sh(1), getopt(3) DIAGNOSTICS
The getopt utility prints an error message on the standard error output and exits with status > 0 when it encounters an option letter not included in optstring. HISTORY
Written by Henry Spencer, working from a Bell Labs manual page. Behavior believed identical to the Bell version. Example changed in FreeBSD version 3.2 and 4.0. BUGS
Whatever getopt(3) has. Arguments containing white space or embedded shell metacharacters generally will not survive intact; this looks easy to fix but isn't. Peo- ple trying to fix getopt or the example in this manpage should check the history of this file in FreeBSD. The error message for an invalid option is identified as coming from getopt rather than from the shell procedure containing the invocation of getopt; this again is hard to fix. The precise best way to use the set command to set the arguments without disrupting the value(s) of shell options varies from one shell ver- sion to another. Each shellscript has to carry complex code to parse arguments halfway correcty (like the example presented here). A better getopt-like tool would move much of the complexity into the tool and keep the client shell scripts simpler. BSD
April 3, 1999 BSD
All times are GMT -4. The time now is 08:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy