In the previous section you got to know how to do a YaST program. Well, normally YCP-scripts are executed involving the whole YaST-machinery, e.g. during installation, which requires correct embedding of the script into the surrounding YCP environment. Fortunately there is a way to let run YCP-scripts isolated, i.e. stand-alone.
To do so we make use of the architectural separation of components featured by YaST. The “command line version” of YaST is called y2base and can usually be found in /usr/lib/YaST2/bin. You could set the PATH to include this location to avoid typing in the full path every time.
$> y2base -h
Usage: y2base [LogOpts] Client [ClientOpts] Server [Generic ServerOpts] [Specific ServerOpts]
LogOptions are:
-l | --logfile LogFile : Set logfile
ClientOptions are:
-s : Get options as one YCPList from stdin
-f FileName : Get YCPValue(s) from file
'(any YCPValue)' : Parameter _IS_ a YCPValue
Generic ServerOptions are:
-p FileName : Evaluate YCPValue(s) from file (preload)
'(any YCPValue)' : Parameter _IS_ a YCPValue to be evaluated
Specific ServerOptions are any options passed on unevaluated.
Examples:
y2base installation qt
Start binary y2base with intallation.ycp as client and qt as server
y2base installation '("test")' qt
Provide YCPValue '"test"' as parameter for client installation
y2base installation qt -geometry 800x600
Provide geometry information as specific server options
|
This help page, showing the possible options in a call of y2base, is rather self-explaining. For the moment the interesting parameters are Client and Server. In Section 2.2.4, “External Programs” we learned that YaST consists of several modules, some of them being client-components and some others being server-components. By invoking YaST in the way displayed above we can connect any client-component with any server-component.
Because a YCP-program (also called YCP-module) can act as a client-component, it is possible to connect it with a server-component suitable of executing it. Since our “Hello, World!”-program displays something on screen, we need to use the UI as server-component in this case. As already said the UI is able to use a text-based console environment as well as a graphical X11 environment which leads to the following two methods of running a YCP-script.
y2base file.ycp qt
This will excute file.ycp in the graphical Qt-UI.
y2base file.ycp ncurses
This will excute file.ycp in the text-based NCurses-UI.