ycp − a Perl module for parsing and writing the YaST2 Communication Protocol


"($symbol, @config) = ycp::ParseTerm ('MyAgentConfig ("/etc/file", false, true, $["a":1, "b":2])');"

"($command, $path, $arg) = ycp::ParseCommand ('Write (.magic.path, "abacadabra")');"

"ycp::Return (["arbitrarily", "complex", "data"]);"


PerlYCPValue is a convention for storing a YCP value in a Perl variable. "ParseYcp" parses YCP string representation into PerlYCPValues.

A PerlYCPValue cannot represent a term but only a term is allowed to initialize an agent in a .scr file. Therefore "ParseTerm" is provided.
string, integer, boolean

Stored as a scalar.


Stored as a reference to a list of PerlYCPValues.


Stored as a reference to a map of PerlYCPValues.


Stored as a reference to a string (starting with a "." as expected).

nil (void)

Stored as an undef.


ParseComand $line

"($command, $path, $arg) = ParseCommand ('Write (.moria.gate, "mellon")');"

Parse a SCR command of the form Command (.some.path, optional_argument)

Returns a three element list ("Command", ".some.path", $argument) where the argument is a "PerlYCPValue" and will be undef if it was not specified. Note that the path is converted to a string.

If there was a parse error, the command or path will be the empty string.

ParseTerm $line

"($symbol, @config) = ParseTerm ('MyAgentConfig ("/etc/file", false, true, $["a":1, "b":2])');"

Parse a YCP term. Note that there can be no other term inside.

Returns a list whose first element is the term symbol as a string (or "" in case of an error) and the remaining elements are the term arguments ("PerlYCPValue")

PathComponents $path_ref

($cmd, $path) = ParseCommand ('`Read (.foo."%gconf.d"."gernel")'
@c = PathComponents (\$path);
if ($c[0] eq '%gconf.d' && $c[1] eq "gernel") {...}

Converts a path (a string reference, "PerlYCPValue") to a list of its components. It deals with the nontrivial parts of path syntax. On error it returns undef.

 .                                           −> ()
  .foo.bar                             −> ('foo', 'bar')
  ."foo"                                 −> ('foo')
  ."double\"quote"             −> ('double"quote')
  ."a.dot"                             −> ('a.dot')


"Return (["arbitrarily", "complex", "data"]);"

Sends a "PerlYCPValue" to the partner YCP component.

If there’s just one argment, scalars are interpreted this way: "true" or "false" are sent as booleans, integers or strings of digits are sent as integers, otherwise as strings. If a second argument exists and is true, all scalars are written as strings. If a second argument exists and is false, all scalars are written as byteblocks.

To send a list, call Return(\@list), not Return(@list). Similarly for a map. You can produce references to anonymous lists with [] and hashes with {}.

The difference from "ycpReturn" is that Return can return scalars directly, strings are properly escaped if needeed and paths can be returned.


If you are running in the main yast process and thus can afford to import YaST::YCP, it is better to use its logging functions because they use log.conf and logging just works. In such case, you should not need to use ycp.pm at all. Instead, "use YaST::YCP (":LOGGING")".

The log output can now be redirected, which will be useful for test suites. If the first command-line option is "−l", the second argument is taken as the log file. A hyphen "−" designates standard output.

Otherwise, /var/log/YaST2/y2log and $HOME/.y2log are tried, in that order.

y2debug, y2milestone, y2warning, y2error, y2security, y2internal

Logs debug messages to /var/log/YaST2/y2log or $HOME/.y2log

Note a semantic change in y2debug: now the environment variable Y2DEBUG is honored so y2debug will not produce output unless this variable is set. This is for compatibility with the logging system in libycp.

Enables output of y2verbose which is used in some of the obsolete functions.


Obsolete. Use (ref($arg) eq " HASH" ) instead.

Obsolete. Use (ref($arg) eq " ARRAY" ) instead.

Not really obsolete because the new parser simply treats integers, booleans and strings as scalars. But who cares, nobody used this anyway.

Not really obsolete because the new parser simply treats integers, booleans and strings as scalars. But who cares, nobody used this anyway.

Obsolete. Use (ref($arg) eq " SCALAR" && $$arg eq "nil") instead.

Obsolete. Use (defined ($arg)) instead.

Obsolete. Use ($command eq "Dir")

Obsolete. Use ($command eq "Read")

Obsolete. Use ($command eq "Write")

Obsolete. Use ($command eq "Execute")

Obsolete. Use ($command eq "result"), note the lowercase ’r’.

Obsolete. Use the return value of "ParseCommand".

Obsolete. Use the return value of "ParseCommand".

Obsolete. Use ref on a return value of "ParseCommand".

Umm, string/integer/boolean?

Obsolete. See "PerlYCPValue".

Obsolete. See "PerlYCPValue".

Obsolete. See "PerlYCPValue".

Obsolete. See PerlYCPValue.

Umm, string/integer/boolean?

Obsolete. Use "Return".

Obsolete. Use "Return"("true" or "false")

Obsolete. Works only on strings not containing backslashes and quotes that would need escaping.

Use "Return".

Obsolete. Works only on list of strings not containing backslashes and quotes that would need escaping.

Use "Return".

Obsolete. Works only on maps of strings not containing backslashes and quotes that would need escaping.

Use "Return".

Obsolete. Use "Return"

Obsolete. Use "ParseCommand".


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.

Free Software

Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.

Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.

Free Books

The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.

Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.

Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.