# Command Line Syntax

The generic syntax is:

    	w3c [ options ]  [ URI [ keywords ]]

Check here the following options

- Getting Help
- Main Modes of execution
- Using Different HTTP Methods
- Data Format Conversions
- Destination Address for PUT and POST
- Other Options
- Form Submission and Searching

Henrik Frystyk Nielsen

## Options

The order of the options is not important and options can in fact be specified on either side of any docaddress. Currently available options are:-

### Getting Help

-help or -?
  Load this file from directly into the browser
-v [ a | b | c | g | p | s | t | u ]
  Verbose mode: Gives a running commentary on the program's attempts to read data in various ways. As the amount of verbose output is substantial, the `-v` option can now be followed by zero, one or more of the following flags (without space) in order to differentiate the verbose output generated:
  - a: Anchor relevant information
  - b: Bindings to local file system
  - c: Cache trace
  - g: SGML trace
  - p: Protocol module information
  - s: SGML/HTML relevant information
  - t: Thread trace
  - u: URI relevant information

  The `-v` option without any appended options shows all trace messages. An example is

      	-vpt

  showing thread and protocol trace messages

-version
  Prints out the version number of the software, and the version number of the WWW library, and exits.

### Main Modes of execution

-
  A minus sign with no trailing characters indicates that the program will accept HTML format input from the standard input. This allows www to be used as a filter from html to plain text for example. Relative links in the input are parsed as though the address of the document was that of the home page (or docaddress if specified). Implies non-interactive mode.
-cl
  Counting content length of the output. This flag appends the Content-Length counter stream to the output stream so that everything is counted. This works exactly like piping the output into wc.
-n
  Non-interactive mode. Outputs the formatted document to the standard output without ever asking for anything. Pages are delimited with form feed (FF) characters.
-o [ file ]
  Redirects output to specified file. The default value is "`w3c.out`". This mode forced non-interactive mode
-single
  Singlethreaded mode. If this flag is set then the browser uses blocking, non interruptible I/O in interactive mode. Non-interactive mode always uses blocking I/O.

### Using Different HTTP Methods

The Command Line Tool supports several HTTP methods. The default value is "GET". These options imply non-interactive execution.

-get
  Gets a document. This is the default operation! See Form Submission and Searching for how to submit HTML forms and to issue queries.
-head
  Returns the header information (if any) but not the document
-delete
  Deletes a resource (or makes it unavailable) for future references.
-put
  Uploads a document from either the local file system or a remote HTTP server to a remote HTTP server (destination) using PUT method. You must indicate the destination using the -dest command line option.
-post
  Uploads a document from either the local file system or a remote HTTP server to a remote HTTP server (destination) using POST method. You must indicate the destination using the -dest command line option. See Form Submission and Searching for how to submit HTML forms and to issue queries.
-options
  Ask for the available options for this URL
-trace
  Ask for trace messages for this URL. You can supply the number of hop counts with the additional -maxforwards command line option

### Automatic Authentication

-auth
  If you are willing to try this then you can include your username, password, and the realm for where to apply it using the -auth command line option. I don't want to hear anything about security, OK? The format is `user:password@realm`

### Data Format Conversions

You can convert the outcome of a request to some other format by using the following flags:

-from [ format ]
  Only if the Line mode Browser is executed as a filter (using the "-" option), this option indicates the desired input format. The default value is "text/html".
-to [ format ]
  Format is the output format for www. Default value is "www/present" but may be changed according to the HTTP-specifications. Two common output formats are "www/source" that is the source without MIME-headers and "www/mime" that is the source with the MIME-header if any. Though also "text/latex" is possible which generates a LaTeX version of the (HTML) document. This can then be compiled using latex and put out as Postscript. Default value is presenting the output to the user.
-source
  Display the original source (without any MIME-headers) of a document instead of parsing it.

### Destination Address for PUT and POST

-dest
  You can specify a (relative) destination URL, for example for the operations `PUT` and `POST` using this flag. For example:

      	-dest http://myserver/newfiles/foo.html

### Other Options

-l [ file ]
  Specifies a log file with a list of visited documents. The default value is "`w3c.log`"
-maxforwards <n>
  Max forwards to be used with the TRACE method
-r <address>
  Rule file, a.k.a. configuration file is a set of rules and configuration options that can be used to map URLs, and to set up other aspects of the behavior of the command line tool. Note that the address must be specified as a URI - and in fact it can be located on HTTP servers etc. as need be. File URIs are parsed relative to the current folder, so a rule file address of "`rules.conf`" will point to a file in the location where this tool it started. If a local file then the file suffix must be "`.conf`" - otherwise the media type must be `application/x-www-rules`.
-timeout <n>
  Timeout in seconds on open connections. If we don't get a reply within n secs then about the request. Default timeout is 20 secs

## URI

If present, the next argument (docaddress) is the hypertext address , of the document at which you want to start browsing. You may want to define an alias for www followed by name of your favorite index.

## Form Submission and Searching

Any further command line arguments are taken as keywords. Keywords can be used for two purposes:

1. As search tokens in an HTTP request-URI encoded so that all spaces are replaced with "`+`" and unsafe characters are encoded using the URI "`%xx`" escape mechanism. This is the default use of keywords.
2. As form data in an HTTP POST request. Use the `-form` command line option to treat all keywords as form data. If the method is GET then the data is encoded as for search data, that is as part of the URI. If it is a POST request then the data is encoded as application/x-www-form-urlencoded and sent in the body of the request.

An example of a search query is

    	w3c http://... "RECORD=ID" "par1=a" "par2=b" "par3=c" "par4=d"

and of a POST form submission

    	w3c -post http://... -form "RECORD=ID" "COL1=a" "COL2=b" "COL3=c" "COL4=d"