Hi,
i am relatively new to programming. i am trying to use an open source library found by google search. the readme file tells to write make on commandline, as a result i got an exe file sample, but now i am trying to chk the output and the usage is:

USAGE
Usage: sample <options>

options:
  -c : Encode input file to output file.
  -d : Decode input file to output file.
  -k [1-7] : Length of binary portion.
  -i <filename> : Name of input file.
  -o <filename> : Name of output file.
  -h|?  : Print out command line options.

-c      Compress the specified input file (see -i) using the Lempel-Ziv-Welch
        encoding algorithm.  Results are written to the specified output file
        (see -o).

-d      Decompress the specified input file (see -i) using the Lempel-Ziv-Welch
        decoding algorithm.  Results are written to the specified output file
        (see -o).  Only files compressed by this program may be decompressed.

-k [1-7]        The number of bits in the binary portion of a Rice encoded
                value.

-i <filename>   The name of the input file.  There is no valid usage of this
                program without a specified input file.

-o <filename>   The name of the output file.  If no file is specified, stdout
                will be used.  NOTE: Sending compressed output to stdout may
                produce undesirable results.

i think i sholud give the command ./sample -c -4 -input.txt -output.txt
but i am getting an error. the error gives description of usuage, which means i ma doing something wrong.
any help is appreciated.additionally, if anyone can refer me to some document describing how to give such commands i will be grateful.

I think you need to be doing this:
./sample -c 4 -i input.txt -o output.txt

i gave the command

./sample -c(compress) -4 (value of k) -1.txt(input file) -2.txt(output file)

but error message says:

Error: k must be between 1 and 7.
Usage: sample <options>

Options:
  -c : Encode input file to output file.
  -d : Decode input file to output file.
  -k [1-7]: Length of binary portion.
  -i <filename> : Name of input file.
  -o <filename> : Name of output file.
  -h | ?  : Print out command line options.

i dont understand where i am wrong. how do i give option for encode and value for k

thanks

That should probably be -k 4 and not just -4 in your example.

@OP: Ah, I thought the -4 was meant to be a value for the -c parameter. I didn't interpret your 1st post properly. I should have noticed that the -c parameter doesn't require a value and that the -4 referred to the -k option.

After seeing your 2nd post, that clears things up massively. Yes L7Sqr is correct. You need to be using -k 4!

So to correctly invoke the program you need to use the following:
./example -c -k 4 -i input.txt -o output.txt

For Future Reference:
When dealing with parameters to programs, you must always specify which parameter you are using. If a parameter takes a value (like with -k in your example program) you put the value after the parameter name. E.g. -k 4.

Sometimes the order of the parameters matters, in other programs it does not. If you are ever unsure of which parameters are mandatory and which are optional and/or the order in which they are supposed to be used there are several ways you can get help.

Getting Help:
On Linux systems, most command line programs will display some help if you invoke them incorrectly. Quite often, using the -h switch as a parameter will display help too. Sometimes programs require --help as a parameter, in rare cases like your 'example' program it might also accept ?.

Many Linux system programs also have detailed help available which can be accessed via the terminal using the man command. So for example if you want to see what options you can pass to the ls command, you can use man ls.

This will give you some brief, but concise information on the ls command. Things like:
A description/synopsis of the program, version, detailed information on the command line arguments it accepts, licensing information, other related man pages etc. You can scroll up and down through the information in the man page using the arrow keys or the page up and page down keys and can quit at any time by pressing q.

Sometimes there may be a program/command which has the same name as a function in a C library. In these cases there are several different man pages set up for each of them.
So for example:
For help with the sleep command/program on the command line, you can use man sleep. But if you want help with the sleep function in the C library, you can use man 3 sleep. The man pages for library functions usually includes information about parameters accepted by the function, the header file you need to include, other related functions and other related man pages (and their page numbers if required) etc.

Also for much more detailed information, you can use the info command.
Using info on it's own will give you some instructions on how to use the info program and lists all available help topics. Using the arrow keys to navigate up and down the list, when you find something you are interested in, you can press the return key to display the help for that topic. On subsequent pages, there may be links to other pages that you can follow using enter.

If you press '?' a popup will display the keys that can be used to navigate backwards and forwards through all of the pages of help that are available. 'x' will hide the help popup. Pressing 'd' will take you back to the top level page of info if you want to get straight back to the main menu. And again, 'q' quits.

Alternatively if you know what you are looking for; instead of browsing through all of the help in info, you can pass some parameters to the info program to go straight to the page you want. So info coreutils ls will bring you up really detailed information about the ls command, (which is part of the coreutils package).

Some programs also use HTML based help which is usually stored in subdirectories in /usr/share/doc/{program_name}/html (where {program_name} is the name of the program/library). So you can use your browser to open these files and browse help/documentation.

There are also a few GUI programs which can keep track of various types of help files installed on your system and will allow you to browse through them.
e.g. DevHelp (for developer related help: Python, GTK+ library, other development libraries etc.), khelpcenter (KDE's default help browser, can access pretty much all help on your system), I'm sure there are several others, but can't name them offhand.

Anyway the point is, there is plenty of help available on any given Linux system if you need it. You just need to know where to look.

Also when installing additional programs/packages on your system, quite often the man pages and help/documentation are stored in a separate package. So if you have enough space on your machine, and there is a help/documentation package available; it's often a good idea to make sure you install it alongside the main package. That way if you get stuck when using a new program (or library, or library function) you can read the manual before asking questions on the internet. Nobody likes being told to RTFM by snooty forum users, but in my experience; 9 times out of 10 I find that all of the information I need is contained in the documentation. Occasionally there might be something that doesn't make sense and needs further clarification. But if you explain (and/or can demonstrate) that you've read the manual and you still don't understand something; very often people are more willing to help, rather than rudely telling you to RTFM.

Anyway, apologies for the wall of text. I hope this monsterous post is of some help!

EDIT:
I forgot to mention apropos, which is another program which can help you to track down man pages on a particular topic. So for example: apropos sleep would list all man pages with sleep in the title.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.