github.com/phobos182/packer@v0.2.3-0.20130819023704-c84d2aeffc68/website/source/docs/command-line/machine-readable.html.markdown (about) 1 --- 2 layout: "docs" 3 page_title: "Machine-Readable Output - Command-Line" 4 --- 5 6 # Machine-Readable Output 7 8 By default, the output of Packer is very human-readable. It uses nice 9 formatting, spacing, and colors in order to make Packer a pleasure to use. 10 However, Packer was built with automation in mind. To that end, Packer 11 supports a fully machine-readable output setting, allowing you to use 12 Packer in automated environments. 13 14 The machine-readable output format is easy to use and read and was made 15 with Unix tools in mind, so it is awk/sed/grep/etc. friendly. 16 17 ## Enabling 18 19 The machine-readable output format can be enabled by passing the 20 `-machine-readable` flag to any Packer command. This immediately enables 21 all output to become machine-readable on stdout. Logging, if enabled, 22 continues to appear on stderr. An example of the output is shown 23 below: 24 25 ``` 26 $ packer -machine-readable version 27 1376289459,,version,0.2.4 28 1376289459,,version-prerelease, 29 1376289459,,version-commit,eed6ece 30 1376289459,,ui,say,Packer v0.2.4.dev (eed6ece+CHANGES) 31 ``` 32 33 The format will be covered in more detail later. But as you can see, 34 the output immediately becomes machine-friendly. Try some other commands 35 with the `-machine-readable` flag to see! 36 37 ## Format 38 39 The machine readable format is a line-oriented, comma-delimeted text 40 format. This makes it extremely to parse using standard Unix tools such 41 as awk or grep in addition to full programming languages like Ruby or 42 Python. 43 44 The format is: 45 46 ``` 47 timestamp,target,type,data... 48 ``` 49 50 Each component is explained below: 51 52 * **timestamp** is a Unix timestamp in UTC of when the message was 53 printed. 54 55 * **target** is the target of the following output. This is empty if 56 the message is related to Packer globally. Otherwise, this is generally 57 a build name so you can relate output to a specific build while parallel 58 builds are running. 59 60 * **type** is the type of machine-readable message being outputted. There 61 are a set of standard types which are covered later, but each component 62 of Packer (builders, provisioners, etc.) may output their own custom types 63 as well, allowing the machine-readable output to be infinitely flexible. 64 65 * **data** is zero or more comma-seperated values associated with the prior 66 type. The exact amount and meaning of this data is type-dependent, so you 67 must read the documentation associated with the type to understand fully. 68 69 Within the format, if data contains a comma, it is replaced with 70 `%!(PACKER_COMMA)`. This was preferred over an escape character such as 71 `\'` because it is more friendly to tools like awk. 72 73 Newlines within the format are replaced with their respective standard 74 escape sequence. Newlines become a literal `\n` within the output. Carriage 75 returns become a literal `\r`. 76 77 ## Message Types 78 79 The set of machine-readable message types can be found in the 80 [machine-readable format](/docs/machine-readable/index.html) 81 complete documentation section. This section contains documentation 82 on all the message types exposed by Packer core as well as all the 83 components that ship with Packer by default.