473,397 Members | 2,028 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,397 software developers and data experts.

using getopt() more than once

Hi,

Any one ever used getopt function more than once. Here is my example.
I have to run a process as

myProcess -x -y -c "-a -f myFile -o myOutput -d debugFile"

First I have to check for -c option and use the value of this -x
argument for next get opt.

Any one has an experience in the same. The reply will be highly
appreciated.

Regards
Praveen Kumar M

Nov 14 '05 #1
2 2086

"Praveen" <pr**********@gmail.com> wrote
Any one ever used getopt function more than once. Here is my example.
I have to run a process as

myProcess -x -y -c "-a -f myFile -o myOutput -d debugFile"

The thing to do in these situations is first, read the documentation for the
function, and second do a bit of exploratory programming. Just get the
options and echo them to stdout.
getopt() is not an ANSI function and it is years since I last used it, so I
couldn't tell you exactly how it works.
Nov 14 '05 #2
Praveen wrote:
Hi,

Any one ever used getopt function more than once. Here is my example.
I have to run a process as

myProcess -x -y -c "-a -f myFile -o myOutput -d debugFile"

First I have to check for -c option and use the value of this -x
argument for next get opt.

Any one has an experience in the same. The reply will be highly
appreciated.

Regards
Praveen Kumar M


I don't really understand what you mean. But in the manner you wrote it
and assuming that -c is specified with an argument ("c:" in the option
string) the string "-a -f myFile -o myOutput -d debugFile" is parsed as
a single argument to -c. Otherwise will be parsed as a positional argument.

I don't think you can parse it using getopt() since it is a single
string not an array of pointers to the single word.

Ciao
Giovanni
--
A computer is like an air conditioner,
it stops working when you open Windows.
Registered Linux user #337974 <http://counter.li.org/>

Nov 14 '05 #3

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
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...
1
by: Shaun Jackman | last post by:
I'd like to call getopt with one set of arguments, and once that's completely done call it again with an entirely different set of arguments. I've found though that at least with the getopt...
18
by: k_over_hbarc | last post by:
What is the correct format of getopt() and how does it work? I looked at the man page; it doesn't really clarify things. What's a program that uses it, maybe I could figure it out from that. ...
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.