These are the main features of the non-interactive (or batch) mode:
You have to specify a command name with the -C option. Specify all options that the command would take in an interactive session as additional options on the command line. The client will execute this command and exit.
The clients accept the input for some commands on stdin. If input is available on stdin, be it through a pipe or from a redirected file, this input will be used and any input from a file with the -f option will be ignored. As mentioned previously, the automatic detection of data on stdin does not work on a few platforms like Windows/Cygwin. In this case, please use the -f stdin option to make the client read from stdin.
The main purpose of the batch mode is to run the clients from shell scripts (or Perl or PHP if you prefer). You can figure out scripts of arbitrary complexity to interact with your reference database.
Note: You will still be prompted for a password unless you specify one with the -w or in the configuration file. Both ways are considered less secure than typing it on the password prompt, but this is a tradeoff if you want unattended operation. Please keep also in mind that the password prompt will fail if you send data to stdin.