getopt does not parse optional arguments to parameters

Although not mentioned in glibc documentation or getopt man page, optional arguments to long style command line parameters require ‘equals sign’ (=). Space separating the optional argument from the parameter does not work. An example run with the test code: $ ./respond –praise John Kudos to John $ ./respond –praise=John Kudos to John $ ./respond … Read more

Optional option argument with getopts

This workaround defines ‘R’ with no argument (no ‘:’), tests for any argument after the ‘-R’ (manage last option on the command line) and tests if an existing argument starts with a dash. # No : after R while getopts “hd:R” arg; do case $arg in (…) R) # Check next positional parameter eval nextopt=\${$OPTIND} … Read more

Why use argparse rather than optparse?

As of python 2.7, optparse is deprecated, and will hopefully go away in the future. argparse is better for all the reasons listed on its original page (https://code.google.com/archive/p/argparse/): handling positional arguments supporting sub-commands allowing alternative option prefixes like + and / handling zero-or-more and one-or-more style arguments producing more informative usage messages providing a much … Read more

Using getopts to process long and short command line options

getopt and getopts are different beasts, and people seem to have a bit of misunderstanding of what they do. getopts is a built-in command to bash to process command-line options in a loop and assign each found option and value in turn to built-in variables, so you can further process them. getopt, however, is an … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)