Difference between revisions of "Cmd.c32"

From Syslinux Wiki
Jump to: navigation, search
m (Wiki formatting.)
m (Add Categories. Add internal links. Wiki formatting.)
 
Line 1: Line 1:
 +
[[Category:Comboot]]
 +
[[Category:Examples]]
 
[[Category:Modules]]
 
[[Category:Modules]]
 
<!-- cmd.c32 can partially replace the need for -->
 
<!-- cmd.c32 can partially replace the need for -->
Line 5: Line 7:
 
<!-- macros -->
 
<!-- macros -->
 
== Introduction ==
 
== Introduction ==
'''cmd.c32''' executes its arguments as if they were typed in directly at the Syslinux prompt.  
+
'''cmd.c32''' executes its arguments as if they were typed-in directly at the Syslinux [[Cli|prompt]].  
It is commonly used to reference other labels within a cfg file.  
+
It is commonly used to reference other labels within a [[config]]uration file.  
It can also partially replace the need for a global append directive and/or variables in a cfg file.  
+
It can also partially replace the need for a global [[Directives/append|append]] directive  
 +
and/or variables in a cfg file.  
 
Let's see some examples.
 
Let's see some examples.
  
 
<br />
 
<br />
  
The following code shows a typical boot menu.
+
The following code shows a typical boot [[menu]].
 
+
{|
<pre>
+
|
 
  UI menu.c32
 
  UI menu.c32
 
   
 
   
  LABEL normal
+
  LABEL <font color="olive">normal</font>
 
  LINUX bzImage
 
  LINUX bzImage
 
  INITRD initrd.img
 
  INITRD initrd.img
 
  APPEND option_1 option_2 option_3
 
  APPEND option_1 option_2 option_3
 
   
 
   
  LABEL live
+
  LABEL <font color="teal">live</font>
 
  LINUX bzImage
 
  LINUX bzImage
 
  INITRD initrd.img
 
  INITRD initrd.img
  APPEND option_1 option_2 option_3 livemedia
+
  APPEND option_1 option_2 option_3 <font color="maroon">livemedia</font>
  # The "live" label entry adds one additional option
+
  # The "<font color="teal">live</font>" label entry adds one additional option
  # in comparison to the "normal" label entry.
+
  # in comparison to the "<font color="olive">normal</font>" label entry.
</pre>
+
|}
 
+
  
 
The following boot methods are equivalent alternatives:
 
The following boot methods are equivalent alternatives:
Line 36: Line 38:
 
* B_ Select the first entry in the above menu; <!--
 
* B_ Select the first entry in the above menu; <!--
 
   --> press {{nowrap|1=<tt>[<nowiki/>TAB]</tt>;}} <!--
 
   --> press {{nowrap|1=<tt>[<nowiki/>TAB]</tt>;}} <!--
   --> typing in {{nowrap|1="<tt>&nbsp;livemedia</tt>"}} <!--
+
   --> typing in {{nowrap|1="<code>&nbsp;<font color="maroon">livemedia</font></code>"}} <!--
 
   --> results in something like <!--
 
   --> results in something like <!--
 
   --> {{nowrap|1="<code>.linux bzImage initrd=initrd.img option_1 option_2 option_3 livemedia</code>";}} <!--
 
   --> {{nowrap|1="<code>.linux bzImage initrd=initrd.img option_1 option_2 option_3 livemedia</code>";}} <!--
 
   --> press {{nowrap|1=<tt>[<nowiki/>ENTER]</tt>.}} Or,
 
   --> press {{nowrap|1=<tt>[<nowiki/>ENTER]</tt>.}} Or,
* C_ In a clean "boot:" prompt, type in "<tt>live</tt>"; <tt>[<nowiki/>ENTER]</tt>. Or,
+
* C_ In a clean "boot:" prompt, type in "<tt><font color="teal">live</font></tt>"; <tt>[<nowiki/>ENTER]</tt>. Or,
* D_ In a clean "boot:" prompt, type in {{nowrap|"<tt>normal livemedia</tt>";}} <tt>[<nowiki/>ENTER]</tt>.
+
* D_ In a clean "boot:" prompt, type in {{nowrap|"<code>normal livemedia</code>";}} <tt>[<nowiki/>ENTER]</tt>.
  
 
<br />
 
<br />
Line 47: Line 49:
  
 
The following label entry is also equivalent:
 
The following label entry is also equivalent:
<pre>
+
{|
 +
|
 
  LABEL live
 
  LABEL live
 
  COM32 cmd.c32
 
  COM32 cmd.c32
  APPEND normal livemedia
+
  APPEND <font color="olive">normal</font> <font color="maroon">livemedia</font>
 
  # Equivalent to typing "normal livemedia" in CLI.
 
  # Equivalent to typing "normal livemedia" in CLI.
</pre>
+
|}
 
By using <tt>cmd.c32</tt> in the cfg file,  
 
By using <tt>cmd.c32</tt> in the cfg file,  
editing the '<tt>APPEND</tt>' line in the '<tt>normal</tt>' boot entry  
+
editing the '<tt>APPEND</tt>' line in the '<tt><font color="olive">normal</font></tt>' boot entry  
 
will directly affect any other boot entry that includes {{nowrap|1='<tt>cmd.c32 normal</tt>'.}}
 
will directly affect any other boot entry that includes {{nowrap|1='<tt>cmd.c32 normal</tt>'.}}
  
Line 61: Line 64:
  
 
The following cfg file:
 
The following cfg file:
<pre>
+
{|
 +
|
 
  UI menu.c32
 
  UI menu.c32
 
   
 
   
  LABEL normal
+
  LABEL <font color="olive">normal</font>
 
  LINUX bzImage
 
  LINUX bzImage
 
  INITRD initrd.img
 
  INITRD initrd.img
Line 88: Line 92:
 
  INITRD initrd.img
 
  INITRD initrd.img
 
  APPEND option_1 option_2 option_3 kbrd=es
 
  APPEND option_1 option_2 option_3 kbrd=es
</pre>
+
|}
 
is equivalent to:
 
is equivalent to:
<pre>
+
{|
 +
|
 
  UI menu.c32
 
  UI menu.c32
 
   
 
   
  LABEL normal
+
  LABEL <font color="olive">normal</font>
 
  LINUX bzImage
 
  LINUX bzImage
 
  INITRD initrd.img
 
  INITRD initrd.img
Line 100: Line 105:
 
  LABEL us
 
  LABEL us
 
  COM32 cmd.c32
 
  COM32 cmd.c32
  APPEND normal kbrd=us
+
  APPEND <font color="olive">normal</font> kbrd=us
 
   
 
   
 
  LABEL de
 
  LABEL de
 
  COM32 cmd.c32
 
  COM32 cmd.c32
  APPEND normal kbrd=de
+
  APPEND <font color="olive">normal</font> kbrd=de
 
   
 
   
 
  LABEL fr
 
  LABEL fr
 
  COM32 cmd.c32
 
  COM32 cmd.c32
  APPEND normal kbrd=fr
+
  APPEND <font color="olive">normal</font> kbrd=fr
 
   
 
   
 
  LABEL es
 
  LABEL es
 
  COM32 cmd.c32
 
  COM32 cmd.c32
  APPEND normal kbrd=es
+
  APPEND <font color="olive">normal</font> kbrd=es
</pre>
+
|}
  
 
Editing the second cfg file is simpler:  
 
Editing the second cfg file is simpler:  
just change the '<tt>normal</tt>' boot entry.
+
just change the '<tt><font color="olive">normal</font></tt>' boot entry.
  
 
<br />
 
<br />
 
== Example (III) ==  
 
== Example (III) ==  
  
Let's take the last boot entry from the above {{nowrap|[[#Example (II)]]:}}
+
Let's take the last boot entry from the above {{nowrap|1=[[#Example (II)]]:}}
 
<pre>
 
<pre>
 
  LABEL es
 
  LABEL es
Line 128: Line 133:
 
</pre>
 
</pre>
  
In the menu,  
+
In the [[menu]],  
 
select this entry and press {{nowrap|1=<tt>[<nowiki/>TAB]</tt>}}  
 
select this entry and press {{nowrap|1=<tt>[<nowiki/>TAB]</tt>}}  
 
so as to edit the command line before acting on it.  
 
so as to edit the command line before acting on it.  
The CLI will show:
+
The [[Cli|CLI]] will show:
 
<pre> >.com32 cmd.c32 normal kbrd=es </pre>
 
<pre> >.com32 cmd.c32 normal kbrd=es </pre>
 
which is shorter than the original:
 
which is shorter than the original:
 +
{|
 +
|
 
<pre> >.linux bzImage initrd=initrd.img option_1 option_2 option_3 kbrd=es </pre>
 
<pre> >.linux bzImage initrd=initrd.img option_1 option_2 option_3 kbrd=es </pre>
 +
|}
  
 
This example shows one '''disadvantage''' of using <tt>cmd.c32</tt>.  
 
This example shows one '''disadvantage''' of using <tt>cmd.c32</tt>.  
 
To get a command line such as:
 
To get a command line such as:
 +
{|
 +
|
 
<pre> >.linux bzImage initrd=initrd.img option_3 kbrd=es </pre>
 
<pre> >.linux bzImage initrd=initrd.img option_3 kbrd=es </pre>
the user needs to select the first entry, '<tt>normal</tt>',  
+
|}
 +
the user needs to select the first entry, '<tt><font color="olive">normal</font></tt>',  
 
press <tt>[<nowiki/>TAB]</tt> and edit the whole command  
 
press <tt>[<nowiki/>TAB]</tt> and edit the whole command  
 
by deleting the unwanted options {{nowrap|('<tt>option_1 option_2</tt>')}}  
 
by deleting the unwanted options {{nowrap|('<tt>option_1 option_2</tt>')}}  
Line 157: Line 168:
 
== Example (V) ==  
 
== Example (V) ==  
  
Changing the <tt>INITRD</tt> is possible. Let's follow the explanation.
+
Changing the [[Config#INITRD|<tt>INITRD</tt>]] is possible. Let's follow the explanation.
  
The '<tt>normal</tt>' entry:
+
The '<tt><font color="olive">normal</font></tt>' entry:
<pre>
+
{|
  LABEL normal
+
|
 +
  LABEL <font color="olive">normal</font>
 
  LINUX bzImage
 
  LINUX bzImage
 
  INITRD initrd.img
 
  INITRD initrd.img
 
  APPEND option_1 option_2 option_3
 
  APPEND option_1 option_2 option_3
</pre>
+
|}
 
is seen in CLI as:
 
is seen in CLI as:
 +
{|
 +
|
 
<pre> >.linux bzImage initrd=initrd.img option_1 option_2 option_3 </pre>
 
<pre> >.linux bzImage initrd=initrd.img option_1 option_2 option_3 </pre>
 +
|}
  
 
Since the last <tt>INITRD</tt> in a boot command overrides previous ones,  
 
Since the last <tt>INITRD</tt> in a boot command overrides previous ones,  
then the following command (with an additional {{nowrap|1='<tt>initrd=new.img</tt>'):}}
+
then the following command  
<pre> >.linux bzImage initrd=initrd.img option_1 option_2 option_3 initrd=new.img </pre>
+
(with an additional {{nowrap|1='<tt><font color="green">initrd=new.img</font></tt>'):}}
 
+
{|
 +
|
 +
&gt;.linux bzImage initrd=initrd.img option_1 option_2 option_3 <font color="green">initrd=new.img</font>  
 +
|}
 
is in fact equivalent to:
 
is in fact equivalent to:
<pre> >.linux bzImage option_1 option_2 option_3 initrd=new.img </pre>
+
{|
 
+
|
 +
&gt;.linux bzImage option_1 option_2 option_3 <font color="green">initrd=new.img</font>  
 +
|}
 
So the following entry in the cfg file:
 
So the following entry in the cfg file:
<pre>
+
{|
 +
|
 
  LABEL new_initrd
 
  LABEL new_initrd
 
  COM32 cmd.c32
 
  COM32 cmd.c32
  APPEND normal initrd=new.img
+
  APPEND <font color="olive">normal</font> <font color="green">initrd=new.img</font>
</pre>
+
|}
uses '<tt>initrd=new.img</tt>' instead of the original '<tt>initrd=initrd.img</tt>'.
+
uses '<tt><font color="green">initrd=new.img</font></tt>'  
 +
instead of the original '<tt>initrd=initrd.img</tt>'.
  
 
<br />
 
<br />
Line 190: Line 212:
  
 
The command line:
 
The command line:
 +
{|
 +
|
 
<pre> >.linux bzImage option_1 option_2 option_3 initrd=initrd.img,new.img </pre>
 
<pre> >.linux bzImage option_1 option_2 option_3 initrd=initrd.img,new.img </pre>
 +
|}
 
uses both, <tt>initrd.img</tt> and <tt>new.img</tt>.  
 
uses both, <tt>initrd.img</tt> and <tt>new.img</tt>.  
 
The following entry is equivalent:
 
The following entry is equivalent:
 +
{|
 +
|
 
<pre>
 
<pre>
 
  LABEL new_initrd_merged
 
  LABEL new_initrd_merged
Line 198: Line 225:
 
  APPEND normal initrd=initrd.img,new.img
 
  APPEND normal initrd=initrd.img,new.img
 
</pre>
 
</pre>
since the original '<tt>initrd=initrd.img</tt>' in '<tt>normal</tt>'  
+
|}
 +
since the original '<tt>initrd=initrd.img</tt>'  
 +
in '<tt><font color="olive">normal</font></tt>'  
 
is "replaced" by the last '<tt>initrd=initrd.img,new.img</tt>'.
 
is "replaced" by the last '<tt>initrd=initrd.img,new.img</tt>'.
  
 
<br />
 
<br />

Latest revision as of 18:34, 15 February 2019

Introduction

cmd.c32 executes its arguments as if they were typed-in directly at the Syslinux prompt. It is commonly used to reference other labels within a configuration file. It can also partially replace the need for a global append directive and/or variables in a cfg file. Let's see some examples.


The following code shows a typical boot menu.

UI menu.c32

LABEL normal
LINUX bzImage
INITRD initrd.img
APPEND option_1 option_2 option_3

LABEL live
LINUX bzImage
INITRD initrd.img
APPEND option_1 option_2 option_3 livemedia
# The "live" label entry adds one additional option
# in comparison to the "normal" label entry.

The following boot methods are equivalent alternatives:

  • A_ Start the second entry in the above menu. Or,
  • B_ Select the first entry in the above menu; press [TAB]; typing in " livemedia" results in something like ".linux bzImage initrd=initrd.img option_1 option_2 option_3 livemedia"; press [ENTER]. Or,
  • C_ In a clean "boot:" prompt, type in "live"; [ENTER]. Or,
  • D_ In a clean "boot:" prompt, type in "normal livemedia"; [ENTER].


Example (I)

The following label entry is also equivalent:

LABEL live
COM32 cmd.c32
APPEND normal livemedia
# Equivalent to typing "normal livemedia" in CLI.

By using cmd.c32 in the cfg file, editing the 'APPEND' line in the 'normal' boot entry will directly affect any other boot entry that includes 'cmd.c32 normal'.


Example (II)

The following cfg file:

UI menu.c32

LABEL normal
LINUX bzImage
INITRD initrd.img
APPEND option_1 option_2 option_3

LABEL us
LINUX bzImage
INITRD initrd.img
APPEND option_1 option_2 option_3 kbrd=us

LABEL de
LINUX bzImage
INITRD initrd.img
APPEND option_1 option_2 option_3 kbrd=de

LABEL fr
LINUX bzImage
INITRD initrd.img
APPEND option_1 option_2 option_3 kbrd=fr

LABEL es
LINUX bzImage
INITRD initrd.img
APPEND option_1 option_2 option_3 kbrd=es

is equivalent to:

UI menu.c32

LABEL normal
LINUX bzImage
INITRD initrd.img
APPEND option_1 option_2 option_3

LABEL us
COM32 cmd.c32
APPEND normal kbrd=us

LABEL de
COM32 cmd.c32
APPEND normal kbrd=de

LABEL fr
COM32 cmd.c32
APPEND normal kbrd=fr

LABEL es
COM32 cmd.c32
APPEND normal kbrd=es

Editing the second cfg file is simpler: just change the 'normal' boot entry.


Example (III)

Let's take the last boot entry from the above #Example (II):

 LABEL es
 COM32 cmd.c32
 APPEND normal kbrd=es

In the menu, select this entry and press [TAB] so as to edit the command line before acting on it. The CLI will show:

 >.com32 cmd.c32 normal kbrd=es 

which is shorter than the original:

 >.linux bzImage initrd=initrd.img option_1 option_2 option_3 kbrd=es 

This example shows one disadvantage of using cmd.c32. To get a command line such as:

 >.linux bzImage initrd=initrd.img option_3 kbrd=es 

the user needs to select the first entry, 'normal', press [TAB] and edit the whole command by deleting the unwanted options ('option_1 option_2') and typing in the additional wanted ones ('kbrd=es').


Example (IV)

More than one additional option can be added to the original label.

 LABEL live_fr
 COM32 cmd.c32
 APPEND normal livemedia kbrd=fr


Example (V)

Changing the INITRD is possible. Let's follow the explanation.

The 'normal' entry:

LABEL normal
LINUX bzImage
INITRD initrd.img
APPEND option_1 option_2 option_3

is seen in CLI as:

 >.linux bzImage initrd=initrd.img option_1 option_2 option_3 

Since the last INITRD in a boot command overrides previous ones, then the following command (with an additional 'initrd=new.img'):

>.linux bzImage initrd=initrd.img option_1 option_2 option_3 initrd=new.img 

is in fact equivalent to:

>.linux bzImage option_1 option_2 option_3 initrd=new.img 

So the following entry in the cfg file:

LABEL new_initrd
COM32 cmd.c32
APPEND normal initrd=new.img

uses 'initrd=new.img' instead of the original 'initrd=initrd.img'.


Example (VI)

Merging more than one INITRD is possible.

The command line:

 >.linux bzImage option_1 option_2 option_3 initrd=initrd.img,new.img 

uses both, initrd.img and new.img. The following entry is equivalent:

 LABEL new_initrd_merged
 COM32 cmd.c32
 APPEND normal initrd=initrd.img,new.img

since the original 'initrd=initrd.img' in 'normal' is "replaced" by the last 'initrd=initrd.img,new.img'.