Arguments in usage statement


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Arguments in usage statement
# 1  
Old 10-07-2014
Arguments in usage statement

Hello,
I have a question regarding the usage statement of a script.

I have 2 parameters "--pto" and "--pto_list". To start the script I will need one of them. Both together are not possible.

How this would be printed out within a usage statement?

My suggestion would be:
Code:
Usage: create_sql -f <filename> -a <add client> --pto | --pto_list <filename> --sim

So, is it possible to seperate them with a pipe?
# 2  
Old 10-07-2014
Its upto you, you can print something like this
Code:
Usage: create_sql -f <filename> -a <add client> --[pto/pto_list] <filename> --sim

This User Gave Thanks to Akshay Hegde For This Post:
# 3  
Old 10-07-2014
Ok. But does this statement not mean that it is optional to take one of these parameters?

Code:
Usage: create_sql -f <filename> -a <add client> --[pto/pto_list] <filename> --sim

But it is not optional to take one of them - because one of them is mandatory...
# 4  
Old 10-07-2014
The square brackets are what I see used to denote a choice usually.

Code:
usage:  ./command --arg1 --arg2 [--arg3 | --arg4]

Don't think there's really a standard for that though.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 10-07-2014
The standard way of doing this (when exactly one of two possible options or operands are required) is to use a two line synopsis:
Code:
Usage: create_sql -f <filename> -a <add client> --pto <filename> --sim
       create_sql -f <filename> -a <add client> --pto_list <filename> --sim

See the cp man page for an example.

The notation:
Code:
Usage: create_sql -f <filename> -a <add client> --pto | --pto_list <filename> --sim

indicates that the only way to use create_sql is to pipe its output to the --pto-list command.
The notation:
Code:
Usage: create_sql -f <filename> -a <add client> [--pto | --pto_list] <filename> --sim

indicates that --pto can be specified or --pto-list can be specified, but not both; and neither one is required.

In all of these usage statements you're saying that -f is a mandatory option that requires a filename option-arument, -a is a mandatory option that requires an add client option-argument, --pto and --pto-list are long options that do not take an option-argument, you have a required filename operand and you have another long-option (--sim) that violates standard Utiiity Syntax Guideline #9 (all options are supposed to appear on the command line before operands). The order in which the -a, -f, --pto, --pto-list, and --sim options appear on the command line does not matter when you invoke the command, but all options should appear before any operands. The standards don't acknowledge the existence of long options either, but they are a common extension that falls into an area that the standards allow but do not require (a condition in the standards known as unspecified behavior).

By convention, if a long option takes an option-argument, that should be shown in a synopsis as --option=argument; not as --option argument to preclude an ambiguity issue with long option optional option-arguments. (Having short option optional option-arguments violates Utiiity Syntax Guideline #7.)
These 4 Users Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

If statement arguments

I'm stuck on a particular problem and need some guidance. I have a file with a name and a phone number in it (teledir.txt). I need to do a $# in a separate script to take a positional parameter and check to see if it is in the file. To quote the question: If one argument is supplied, check... (6 Replies)
Discussion started by: Eric7giants
6 Replies

2. Shell Programming and Scripting

Ps -ef|grep <processname> usage in IF statement

Hi, Am working in a filenet domain where we are using AIX as our terminal to run the jobs and schedule the shell scripts to run . In my previous post regarding the "Log modification with finding errors" ... (12 Replies)
Discussion started by: Kalaihari
12 Replies

3. Programming

Passing arguments from command line to switch case statement in C

Hi Am pretty new to C.. Am trying to pass the arguments from command line and use them in switch case statement.. i have tried the following #include <stdlib.h> main(int argc, char* argv) { int num=0; if ( argc == 2 ) num = argv; printf("%d is the num value",num); switch ( num ) ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

4. Shell Programming and Scripting

creating printf statement using user arguments

I am writing a script in bash and want to perform the operation I check number of arguments and make a print statement with the passes arguments If I pass 3 arguments I will do printf "$frmt" "$1" "$2" "$3"If I have 4 arguments I do printf "$frmt" "$1" "$2" "$3" "$4"etc (4 Replies)
Discussion started by: kristinu
4 Replies

5. Shell Programming and Scripting

case statement for different cmd arguments

Hello friends, I have a boubt passing different arguments at a time for any one option in below code. I would also like to check which option has been selected (any one of i, r, u ) so that whether or not matching argument passed can be verified. for i and r - install and re-install -... (4 Replies)
Discussion started by: pd2
4 Replies

6. Shell Programming and Scripting

Usage: optional and mandatory arguments

I have an awk script which can be used in the following ways: xi and xf will only be mandatory when processing the file fin.zc. awk -v xi=0/-0.5 -v xf=80/30 -f ./zc2cmd.awk fin.zc > fout.cmod awk -f ./zc2cmd.awk -u awk -f ./zc2cmd.awk --usg awk -f ./zc2cmd.awk -e awk -f ./zc2cmd.awk... (1 Reply)
Discussion started by: kristinu
1 Replies

7. Shell Programming and Scripting

usage of case statement in place of IF elif...

Hi, I need to carry out the back up of the data if exists...(file size not equal to zero) i tried in this way but it is not successful....where am making the mistakes? and if possible can i use case syntax in place of "if" #!/bin/ksh filename=`TZ=CST+24 date +%Y%m%d` ZERO=0... (3 Replies)
Discussion started by: aemunathan
3 Replies

8. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

9. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

10. Shell Programming and Scripting

if statement - how can I do 2 arguments?

I am new to shell, and I am trying to do a if statement like the following: if ; then basically it works fine if both arguments of the if are met, however the next elif is: elif ; then if the conditions of the elif are met, then it says "final1.sh: line 67: [: too many arguments" ... (6 Replies)
Discussion started by: Darklight
6 Replies
Login or Register to Ask a Question