473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

getopt help required

suppose i have a program in which there are two arguements 'a' and 'b'

the program is such that i will work iff
-either 'a' or 'b' is present as an option to it
-both 'a' and 'b' cant be present sameltaneously
-either of the two should be there

I want to know is there any way in the function getopt or getopt_long
that can help me in doing this
Thanks in advance

Feb 18 '08 #1
6 1877
Rishi wrote:
suppose i have a program in which there are two arguements 'a' and 'b'

the program is such that i will work iff
-either 'a' or 'b' is present as an option to it
-both 'a' and 'b' cant be present sameltaneously
-either of the two should be there

I want to know is there any way in the function getopt or getopt_long
that can help me in doing this
Well, I'm not sure this is on topic here (comp.unix.programmer might be
better), but AFAIK getopt can set a boolean flag on encountering an
option; just do this, and check afterwards your conditions against the
two flag-variables and take appropriate action.

Daniel

--
Done: Bar-Sam-Val-Wiz, Dwa-Elf-Hum-Orc, Cha-Law, Fem-Mal
Underway: Ran-Gno-Neu-Fem
To go: Arc-Cav-Hea-Kni-Mon-Pri-Rog-Tou
Feb 18 '08 #2
In article <f9**********************************@j28g2000hsj. googlegroups.com>,
Rishi <po*******@gmail.comwrote:
>suppose i have a program in which there are two arguements 'a' and 'b'

the program is such that i will work iff
-either 'a' or 'b' is present as an option to it
-both 'a' and 'b' cant be present sameltaneously
-either of the two should be there

I want to know is there any way in the function getopt or getopt_long
that can help me in doing this
Thanks in advance
Off topic. Not portable. Cant discuss it here. Blah, blah, blah.

--
Useful clc-related links:

http://en.wikipedia.org/wiki/Aspergers
http://en.wikipedia.org/wiki/Clique
http://en.wikipedia.org/wiki/C_programming_language

Feb 18 '08 #3

"Rishi" <po*******@gmail.comwrote in message
news:f9**********************************@j28g2000 hsj.googlegroups.com...
suppose i have a program in which there are two arguements 'a' and 'b'

the program is such that i will work iff
-either 'a' or 'b' is present as an option to it
-both 'a' and 'b' cant be present sameltaneously
-either of the two should be there

I want to know is there any way in the function getopt or getopt_long
that can help me in doing this
I've got an options parser on my website that may do what you want.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Feb 18 '08 #4
Rishi wrote:
suppose i have a program in which there are two arguements 'a' and 'b'

the program is such that i will work iff
-either 'a' or 'b' is present as an option to it
-both 'a' and 'b' cant be present sameltaneously
-either of the two should be there

I want to know is there any way in the function getopt or getopt_long
that can help me in doing this
getopt is not part of the language, it's a Posix library function, so
it's not really on-topic here.
Depending on whether you really want the Posix version or the GNU
variant, you'd need to look in slightly different places.

As far as I can see from a brief examination, neither provide an easy
way of making options/arguments mutually exclusive.
Feb 18 '08 #5
Rishi <po*******@gmail.comwrites:
suppose i have a program in which there are two arguements 'a' and 'b'

the program is such that i will work iff
-either 'a' or 'b' is present as an option to it
-both 'a' and 'b' cant be present sameltaneously
-either of the two should be there

I want to know is there any way in the function getopt or getopt_long
that can help me in doing this
Ask in comp.unix.programmer.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Feb 18 '08 #6
On 18 Feb 2008 at 17:21, Keith Thompson wrote:
Rishi <po*******@gmail.comwrites:
>suppose i have a program in which there are two arguements 'a' and 'b'

the program is such that i will work iff
-either 'a' or 'b' is present as an option to it
-both 'a' and 'b' cant be present sameltaneously
-either of the two should be there

I want to know is there any way in the function getopt or getopt_long
that can help me in doing this

Ask in comp.unix.programmer.
Ah, how the warmth and friendliness shine from every one of Kiki's
words!

Feb 18 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: David Bear | last post by:
I'm stumped. Trying to follow the docs and .. failure. here's the args >>> args '-Middwb@mainex1.asu.edu -AKHAAM@prlinux+898 -CA --D2003-08-20-09:28:13.417 -Ff -Hprlinux...
3
by: Dominik Kaspar | last post by:
I tried to use getopt and copied the example from: http://www.python.org/doc/current/lib/module-getopt.html but nothing is working... getopt.GetoptError doesn't seem to exist and when i run the...
3
by: Don Low | last post by:
Hi, I'm going over a script that demonstrates the getopt function. I include the script here: #! /usr/bin/python import sys, getopt, string
6
by: Frans Englich | last post by:
Hello, In my use of getopt.getopt, I would like to make a certain parameter mandatory. I know how to specify such that a parameter must have a value if it's specified, but I also want to make...
14
by: José de Paula | last post by:
Is getopt() and its companions, commonly found in GNU libc and other Unices libc, part of the C standard? Another doubt: I have a switch inside a while loop; is there a way to break out of the...
4
by: pinkfloydhomer | last post by:
I want to be able to do something like: myscript.py * -o outputfile and then have the shell expand the * as usual, perhaps to hundreds of filenames. But as far as I can see, getopt can only...
1
by: Daniel Mark | last post by:
Hello all: I am using getopt package in Python and found a problem that I can not figure out an easy to do . // Correct input D:\>python AddArrowOnImage.py --imageDir=c:/ // Incorrect...
2
by: auditory | last post by:
I have sources written on linux quite long ago. They are compiled good on current linux machine. but not in VS2005. The cause of problem is #include<getopt.h>. Is there any correspoinding...
20
by: Casey | last post by:
Is there an easy way to use getopt and still allow negative numbers as args? I can easily write a workaround (pre-process the tail end of the arguments, stripping off any non-options including...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.