Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
cmd:goto [2011/03/23 19:30]
mcb30
cmd:goto [2013/08/01 14:21]
mcb30
Line 29: Line 29:
 ===== See also ===== ===== See also =====
  
 +  * ''​[[:​cmd:​inc]]''​
   * ''​[[:​cmd:​exit]]''​   * ''​[[:​cmd:​exit]]''​
   * iPXE [[:​scripting|scripting]] guide   * iPXE [[:​scripting|scripting]] guide
Line 34: Line 35:
  
 ===== Notes ===== ===== Notes =====
 +
 +If you are using ''​goto''​ to jump to a label when an operation succeeds, then you must also consider what would happen if the operation were to fail.  For example:
 +
 +    dhcp && goto dhcp_ok
 +
 +If the ''​[[:​cmd:​dhcp]]''​ command fails, then the script will immediately terminate, as described in the [[:​scripting#​error_handling|scripting guide]]. ​ To avoid this problem, you can use the ''​||''​ operator:
 +
 +    dhcp && goto dhcp_ok ||
  
 As with all iPXE commands, any [[:​settings]] such as ${hostname} will be expanded. ​ It is therefore possible to use a dynamically-generated label as the target for the ''​goto''​ command. ​ For example, if the hostname provided by DHCP is ''​thinclient1'',​ then the command As with all iPXE commands, any [[:​settings]] such as ${hostname} will be expanded. ​ It is therefore possible to use a dynamically-generated label as the target for the ''​goto''​ command. ​ For example, if the hostname provided by DHCP is ''​thinclient1'',​ then the command
Line 56: Line 65:
    :​unknown    :​unknown
    echo Unknown host ${hostname}    echo Unknown host ${hostname}
 +
 +You can construct simple loops using the ''​[[:​cmd:​inc]]''​ and ''​[[:​cmd:​iseq]]''​ commands.
  
cmd/goto.txt ยท Last modified: 2013/08/01 14:21 by mcb30
Recent changes RSS feed CC Attribution-Share Alike 4.0 International Driven by DokuWiki
All uses of this content must include an attribution to the iPXE project and the URL https://ipxe.org
References to "iPXE" may not be altered or removed.