# The command line interface

## Gretl at the console

The gretl package includes the command-line program gretlcli. On Linux it can be run from the console, or in an xterm (or similar). Under MS Windows it can be run in a console window (sometimes inaccurately called a DOS box). gretlcli has its own help file, which may be accessed by typing help at the prompt. It can be run in batch mode, sending outout directly to a file (see above).

If gretlcli is linked to the readline library (this is automatically the case in the MS Windows version; also see ), the command line is recallable and editable, and offers command completion. You can use the Up and Down arrow keys to cycle through previously typed commands. On a given command line, you can use the arrow keys to move around, in conjunction with Emacs editing keystokes. Actually, the key bindings shown below are only the defaults; they can be customized. See the readline manual. The most common of these are:

Keystroke | Effect
--- | ---
`Ctrl-a` | go to start of line
`Ctrl-e` | go to end of line
`Ctrl-d` | delete character to right

where `Ctrl-a` means press the `a` key while the `Ctrl` key is also depressed. Thus if you want to change something at the beginning of a command, you don't have to backspace over the whole line, erasing as you go. Just hop to the start and add or delete characters.

If you type the first letters of a command name then press the Tab key, readline will attempt to complete the command name for you. If there's a unique completion it will be put in place automatically. If there's more than one completion, pressing Tab a second time brings up a list.

## Changes from Ramanathan's ESL

gretlcli inherits its basic command syntax from Ramu Ramanathan's ESL, and command scripts developed for ESL should be usable with few or no changes: the only things to watch for are multi-line commands and the `freq` command.

- In ESL, a semicolon is used as a terminator for many commands. I decided to remove this in gretlcli. Semicolons are simply ignored, apart from a few special cases where they have a definite meaning: as a separator for two lists in the `ar` and `tsls` commands, and as a marker for an unchanged starting or ending observation in the `smpl` command. In ESL semicolon termination gives the possibility of breaking long commands over more than one line; in gretlcli this is done by putting a trailing backslash `\` at the end of a line that is to be continued.

- With `freq`, you can't at present specify user-defined ranges as in ESL. A chi-square test for normality has been added to the output of this command.

Note also that the command-line syntax for running a batch job is simplified. For ESL you typed, e.g.

            esl -b datafile < inputfile > outputfile

while for gretlcli you type:

    	gretlcli -b inputfile > outputfile

The inputfile is treated as a program argument; it should specify a datafile to use internally, using the syntax `open datafile` or the special comment `(* !` datafile `*)`