getopt-long Questions

6

Solved

I'm making a small program in C that deals with a lot of command line arguments, so I decided to use getopt to sort them for me. However, I want two non-option arguments (source and destination fi...
Kavanagh asked 6/8, 2013 at 11:48

4

Solved

In C, getopt_long does not parse the optional arguments to command line parameters parameters. When I run the program, the optional argument is not recognized like the example run below. $ ./resp...
Argybargy asked 27/6, 2009 at 12:15

2

Solved

#!/usr/bin/perl -sw use strict; use warnings; use Getopt::Long; my $remote = 0; my $test = 0; GetOptions ('remote' => \$remote, 'test' => \$test); print "$remote:$test\n"; perl test.pl --r...
Endymion asked 22/8, 2012 at 16:9

2

I need help using getoptlong class in Ruby. I need to execute command prog_name.ruby -u -i -s filename. So far I can only execute it with prog_name.ruby -u filename -i filename -s filename. This i...
Handful asked 16/4, 2011 at 18:39

4

Solved

#include <iostream> #include <getopt.h> #define no_argument 0 #define required_argument 1 #define optional_argument 2 int main(int argc, char * argv[]) { std::cout << "Hello"...
Herron asked 10/1, 2012 at 19:20

3

Solved

Is it possible to turn off abbreviation in getopt_long()? From the man page: Long option names may be abbreviated if the abbreviation is unique or is an exact match for some defined option. I wan...
Haug asked 3/3, 2011 at 14:29

1

Solved

I am trying to learn to use getopt_long. From wikipedia, I see the code #include <stdio.h> /* for printf */ #include <stdlib.h> /* for exit */ #include <getopt.h> /* for getopt_lo...
Cochrane asked 10/10, 2016 at 20:11

4

Solved

In Perl's Getopt::Long version 2.39 I could use use Getopt::Long qw( :config gnu_getopt ); GetOptions( \my %opts, "codon-view|c:20", # Optional value, default 20 "consensus|C:50", ... ) t...
Ergotism asked 1/6, 2016 at 21:35

1

I am trying to change my working script with getopts to getopt ( long flags ). Below i present my code which is working. getopts 'm:' mode modeValue=$OPTARG getopts 'p:' parameter parameterValue...
Nicolasanicolau asked 7/8, 2015 at 5:30

1

I'm developing an update in an existing program. I'm replacing Posix's getopt_long() with boost::program_options. But my work doesn't work as I should: I want to have read arguments like: -server=...
Jillene asked 24/12, 2014 at 11:22

1

Solved

I am working on trying to take in command line arguments. If I want to have multiple optional command line arguments how would I go about doing that? For example you can run the program in the foll...
Carrier asked 24/1, 2015 at 18:56

5

Solved

According to the documentation on python's getopt (I think) the options fields should behave as the getopt() function. However I can't seem to enable optional parameters to my code: #!/usr/bin/pyt...
Misstate asked 7/10, 2009 at 16:30

4

Is there a standard way of adding a help function to a script? The simplest way would maybe to take an argument and print some text if it's "-help" or something. Does anyone have any examples on ho...

1

Solved

I've just been asked for the first time in a code review to check the return code from a call to the GetOptions() function of the Getopt::Long Perl module. I cannot remember ever seeing such a tes...
Pris asked 17/7, 2012 at 16:7

2

Solved

I am using the Getopt::Long module to process command line arguments. The typical behavior of this module is we could pass -f instead of full name of the variable --file. At the same time if I hav...
Orange asked 28/6, 2012 at 11:28

1

Solved

I have a script which can get tens of arguments/flags using Getopt::Long. Certain flags are not allowed to be mixed, such as: --linux --unix are not allowed to be supplied together. I know I can ch...
Aniseikonia asked 24/4, 2012 at 13:34

1

Solved

Using the in a C++ program, Eclipse CDT marks getopt_long as "could not be resolved". The code compiles and runs fine using g++ program.cpp. Has this something to do with the Eclipse build set up? ...
Misadventure asked 22/1, 2012 at 14:57

1

Solved

My goal is to have a --override=f option that manipulates the values of two other options. The trick is figuring out how to refer to the option's value (the part matching the f in the =f designator...
Zoellick asked 12/3, 2011 at 7:12

1

Solved

I want to support both short and long options in bash scripts, so one can: $ foo -ax --long-key val -b -y SOME FILE NAMES is it possible?
Propylene asked 15/11, 2010 at 2:2

3

Solved

If I have a command line like: my_script.pl -foo -WHATEVER My script knows about --foo, and I want Getopt to set variable $opt_foo, but I don't know anything about -WHATEVER. How can I tell Geto...
Tuckerbag asked 8/6, 2010 at 23:22

2

Solved

When getopt or getopt_long encounters an illegal option, it stores the offending option character in optopt. When the illegal option is a long option, where can I find out what the option was? And ...
Haw asked 27/4, 2010 at 18:25

1

Solved

If i do this: GetOptions( 'u=s' => \$in_username, 'r=i' => \$in_readonly, 'b=i' => \$in_backup ); exit usage() unless $in_username && $in_readonly && $in_backup; an...
Falkner asked 10/3, 2010 at 15:7

5

Solved

I have a string with possible command line arguments (using an Read-Eval-Print-Loop program) and I want it to be parsed similar to the command line arguments when passed to Getopt::Long. To elabor...
Titter asked 22/9, 2008 at 23:52
1

© 2022 - 2024 — McMap. All rights reserved.