Skip to content
Snippets Groups Projects
NuttShell.html 68.4 KiB
Newer Older
patacongo's avatar
patacongo committed
<html>
<head>
patacongo's avatar
patacongo committed
<title>NuttShell</title>
patacongo's avatar
patacongo committed
</head>
<body background="backgd.gif">
<hr><hr>
<table width ="100%">
  <tr align="center" bgcolor="#e4e4e4">
    <td>
      <h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
      <p>Last Updated: March 7, 2011</p>
patacongo's avatar
patacongo committed
    </td>
  </tr>
</table>
<hr><hr>
<table width ="100%">
  <tr bgcolor="#e4e4e4">
    <td>
  <h1>Table of Contents</h1>
    </td>
  </tr>
</table>

<center><table width ="80%">
<tr>
<td>
<table>
<tr>
patacongo's avatar
patacongo committed
  <td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
patacongo's avatar
patacongo committed
  <td>
    <a href="#overview">1.0 Overview</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#frontend">1.1 Console/NSH Front End</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdoverview">1.2 Command Overview</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#conditional">1.3 Conditional Command Execution</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#builtinvars">1.4 Built-In Variables</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#currentwd">1.5 Current Working Directory</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#environvars">1.6 Environment Variables</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#startupscript">1.7 NSH Start-Up Script</a>
  </td>
</tr>
patacongo's avatar
patacongo committed

<tr>
patacongo's avatar
patacongo committed
  <td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
patacongo's avatar
patacongo committed
  <td>
    <a href="#commands">2.0 Commands</a>.
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdtest">2.1 Evaluate Expression (test)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdcat">2.2 Concatenate Files (cat)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdcd">2.3 Change Current Working Directory (cd)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdcp">2.4 Copy Files (cp)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmddd">2.5 Copy and Convert Files (dd)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdecho">2.6 Echo Strings and Variables (echo)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdexec">2.7 Execute User Code (exec)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdexit">2.8 Exit NSH (exit)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdfree">2.9 Show Memory Manager Status (free)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdget">2.10 Get File Via TFTP (get)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdhelp">2.11 Show Usage Command Usage (help)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdifconfig">2.12 Show Network Configuration (ifconfig)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdkill">2.13 Send a signal to a task (kill)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdlosetup">2.14 Setup/teardown the Loop Device (losetup)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdls">2.15 List Directory Contents (ls)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdmbhw">2.16 Access Memory (mb, mh, and mw)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdps">2.17 Show Current Tasks and Threads (ps)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdmkdir">2.18 Create a Directory (mkdir)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdmkfatfs">2.19 Create a FAT Filesystem (mkfatfs)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdmkfifo">2.20 Create a FIFO (mkfifo)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdmkrd">2.21 Create a RAMDISK (mkrd)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdmount">2.22 Mount a File System (mount)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdping">2.23 Check Network Peer (ping)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdput">2.24 Send File Via TFTP (put)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdpwd">2.25 Show Current Working Directory (pwd)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdrm">2.26 Remove a File (rm)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdrmdir">2.27 Remove a Directory (rmdir)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdset">2.28 Set an Environment Variable (set)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdsh">2.29 Execute an NSH Script (sh)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdsleep">2.30 Wait for Seconds (sleep)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
patacongo's avatar
patacongo committed
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdunmount">2.31 Unmount a File System (umount)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdunset">2.32 Unset an Environment Variable (unset)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdusleep">2.33 Wait for Microseconds (usleep)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
patacongo's avatar
patacongo committed
    <a href="#cmdwget">2.34 Get File Via HTTP (wget)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdxd">2.35 Hexadecimal Dump (xd)</a>
patacongo's avatar
patacongo committed
  </td>
</tr>
patacongo's avatar
patacongo committed
<tr>
patacongo's avatar
patacongo committed
  <td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
patacongo's avatar
patacongo committed
  <td>
    <a href="#configuration">3.0 Configuration Settings</a>
</td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmddependencies">3.1 Command Dependencies on Configuration Settings</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#nshconfiguration">3.2  NSH-Specific Configuration Settings</a>
  </td>
</tr>
patacongo's avatar
patacongo committed
<tr>
patacongo's avatar
patacongo committed
  <td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
patacongo's avatar
patacongo committed
  <td>
    <a href="#index">Index</a>
</td>
patacongo's avatar
patacongo committed
</table>
</td>
</tr>
</table></center>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="overview"><h1>1.0 Overview</h1></a>
  </td>
  </tr>
</table>

<p>
  The <code>examples/nsh</code> sub-directory contains the NuttShell (NSH).
  NSH is a simple shell application for NuttX.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="frontend"><h2>1.1 Console/NSH Front End</h2></a>
  </td>
  </tr>
</table>

<p>
  Using settings in the configuration file, NSH may be configured to
  use either the serial stdin/out or a telnet connection as the console
  or BOTH.  When NSH is started, you will see the following welcome on
  either console:
  <ul><pre>
NuttShell (NSH)
nsh&gt;
</pre></ul>
  <code>nsh&gt;</code> is the NSH prompt and indicates that you may enter a command
   from the console.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdoverview"><h2>1.2 Command Overview</h2></a>
  </td>
  </tr>
</table>

<p>
  <b>Simple, Re-directed, and Background Commands</b>.
  The NuttShell (NSH) is a simple shell application.
  NSH supports the following commands forms:
</p>
<ul><table>
  <tr>
     <td>Simple command:</td>
     <td><code>&lt;cmd&gt;</code></td>
  </tr>
  <tr>
     <td>Command with re-directed output:</td>
     <td><code>
         &lt;cmd&gt; &gt; &lt;file&gt;<br>
         &lt;cmd&gt; &gt;&gt; &lt;file&gt;
     </code></td>
  </tr>
  <tr>
     <td>Background command:</td>
     <td><code>&lt;cmd&gt; &amp;</code></td>
  </tr>
  <tr>
     <td>Re-directed background command:</td>
     <td><code>
       &lt;cmd&gt; &gt; &lt;file&gt; &amp;<br>
       &lt;cmd&gt; &gt;&gt; &lt;file&gt; &amp;
     </code></td>
  </tr>
</table></ul>
<p>Where:</p>
<ul><table>
  <tr>
    <td><code>&lt;cmd&gt;</code></td>
    <td>
      is any one of the simple commands listed later.
    </td>
  </tr>
  <tr>
    <td><code>&lt;file&gt;</code></td>
    <td>
      is the full or relative path to any writable object
      in the filesystem name space (file or character driver).
      Such objects will be referred to simply as files throughout
      this document.
    </td>
  </tr>
</table></ul>
<p>
  <b><big><code>nice</code></big>'d Background Commands</b>
  NSH executes at the mid-priority (128).  Backgrounded commands can
  be made to execute at higher or lower priorities using <code>nice</code>:
</p>
<ul><code>
  [nice [-d &lt;niceness&gt;&gt;]] &lt;cmd&gt; [&gt; &lt;file&gt;|&gt;&gt; &lt;file&gt;] [&amp;]
</code></ul>
<p>
  Where <code>&lt;niceness&gt;</code> is any value between -20 and 19 where lower
  (more negative values) correspond to higher priorities.
  The default niceness is 10.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="conditional"><h2>1.3 Conditional Command Execution</h2></a>
  </td>
  </tr>
</table>

<p>
  An <code>if-then[-else]-fi</code> construct is also supported in order to
  support conditional execution of commands.  This works from the
  command line but is primarily intended for use within NSH scripts
  (see the <a href="#cmdsh"><code>sh</code></a> commnd).  The syntax is as follows:
</p>
<ul><pre>
if &lt;cmd&gt;
then
  [sequence of &lt;cmd&gt;]
else
  [sequence of &lt;cmd&gt;]
fi
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="builtinvars"><h2>1.4 Built-In Variables</h2></a>
  </td>
  </tr>
</table>

<ul><table>
  <tr>
    <td valign="top"><b><code>$?</code></b></td>
    <td>
      The result of the last simple command execution.
      On backgrounded commands, this variable holds only the result of spawning the background command.
    </td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="currentwd"><h2>1.5 Current Working Directory</h2></a>
  </td>
  </tr>
</table>

<p>
  <b><code>cd</code> and <code>pwd</code></b>.
  All path arguments to commands may be either an absolute path or a
  path relative to the current working directory.  The current working
patacongo's avatar
patacongo committed
  directory is set using the <a href="#cmdcd"><code>cd</code></a> command and can be queried either
patacongo's avatar
patacongo committed
  by using the <a href="#cmdpwd"><code>pwd</code></a> command or by
  using the <a href="#cmdecho"><code>echo</code></a> <a href="#environvars"><code>$PWD</code></a>
  command.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="environvars"><h2>1.6 Environment Variables</h2></a>
  </td>
  </tr>
</table>

<p>
  <b>Environment Variables:</b>
</p>
<ul><table>
  <tr>
    <td><b><code>PWD</code></b></td><td>The current working directory</td>
  </tr>
  <tr>
    <td><b><code>OLDPWD</code></b></td><td>The previous working directory</td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="startupscript"><h2>1.7 NSH Start-Up Scrip</h2></a>
  </td>
  </tr>
</table>

<p>
  <b>NSH Start-Up Script</b>.
  NSH supports options to provide a start up script for NSH.  In general
  this capability is enabled with <code>CONFIG_EXAMPLES_NSH_ROMFSETC</code>, but has
  several other related configuration options as described with the
  <a href="#nshconfiguration">NSH-specific configuration settings</a>.
  This capability also depends on:
  <ul>
    <li><code>CONFIG_DISABLE_MOUNTPOINT</code> not set
    <li><code>CONFIG_NFILE_DESCRIPTORS</code> &lt; 4
    <li><code>CONFIG_FS_ROMFS</code> enabled
  </ul>
</p>

<p>
  <b>Default Start-Up Behavior</b>.
  The implementation that is provided is intended to provide great flexibility
  for the use of Start-Up files.  This paragraph will discuss the general
  behavior when all of the configuration options are set to the default
  values.
</p>
<p>
  In this default case, enabling <code>CONFIG_EXAMPLES_NSH_ROMFSETC</code> will cause
  NSH to behave as follows at NSH startup time:
  <ul>
    <li>
      NSH will create a read-only RAM disk (a ROM disk), containing a tiny
      ROMFS filesystem containing the following:
<ul><pre>
`--init.d/
     `-- rcS
</pre></ul>
      Where rcS is the NSH start-up script.
    </li>
    <li>
      NSH will then mount the ROMFS filesystem at <code>/etc</code>, resulting in:
<ul><pre>
|--dev/
|   `-- ram0
`--etc/
    `--init.d/
        `-- rcS
</pre></ul>
    </li>
    <li>
      By default, the contents of rcS script are:
<ul><pre>
# Create a RAMDISK and mount it at XXXRDMOUNTPOUNTXXX

mkrd -m 1 -s 512 1024
mkfatfs /dev/ram1
mount -t vfat /dev/ram1 /tmp
</pre></ul>
    </li>
    <li>
      NSH will execute the script at <code>/etc/init.d/rcS</code> at start-up (before the
      first NSH prompt.  After execution of the script, the root FS will look
      like:
<ul><pre>
|--dev/
|   |-- ram0
|   `-- ram1
|--etc/
|   `--init.d/
|       `-- rcS
`--tmp/
</pre></ul>
    </li>
  </ul>
</p>
<p>
  <b>Modifying the ROMFS Image</b>.
  The contents of the <code>/etc</code> directory are retained in the file <code>examples/nsh/nsh_romfsimg.h</code> OR, if <code>CONFIG_EXAMPLES_NSH_ARCHROMFS</code> is defined, <code>include/arch/board/rcs.template</code>).
  In order to modify the start-up behavior, there are three things to study:
  <ol>
    <li>
      <b>Configuration Options.</b>
      The additional <code>CONFIG_EXAMPLES_NSH_ROMFSETC</code> configuration options
      discussed with the other <a href="#nshconfiguration">NSH-specific configuration settings</a>.
    </li>
    <li>
      <p>
        <b><code>tools/mkromfsimg.sh</code> Script</b>.
        The script <code>tools/mkromfsimg.sh</code> creates <code>nsh_romfsimg.h</code>.
        It is not automatically executed.  If you want to change the
        configuration settings associated with creating and mounting
        the <code>/tmp</code> directory, then it will be necessary to re-generate
        this header file using the <code>tools/mkromfsimg.sh</code> script.
      </p>
      <p>
        The behavior of this script depends upon three things:
        <ul>
          <li>The configuration settings then installed configuration.
          <li>The <code>genromfs<code> tool (available from <a href="http://romfs.sourceforge.net">http://romfs.sourceforge.net</a>).
          <li>The file <code>examples/nsh/rcS.template</code>
		    (OR, if <code>CONFIG_EXAMPLES_NSH_ARCHROMFS</code> is defined <code>include/arch/board/rcs.template</code>.
        </ul>
      </p>
    </li>
    <li>
      <b><code>rcS.template</code></b>.
      The file <code>examples/nsh/rcS.template</code> contains the general form
      of the <code>rcS</code> file; configured values are plugged into this
      template file to produce the final <code>rcS</code> file.
    </li>
  </ol>
</p>
<p>
  <b>NOTE</b>:
  <code>examples/nsh/rcS.template</code> generates the standard, default <code>nsh_romfsimg.h</code> file.
  If <code>CONFIG_EXAMPLES_NSH_ARCHROMFS<code> is defined in the NuttX configuration file, then a custom, board-specific <code>nsh_romfsimg.h</code> file residing in <code>configs/&lt;board&gt;/include</code> will be used.
  NOTE when the OS is configured, <code>include/arch/board</code> will be linked to <code>configs/&lt;board&gt;/include</code>.
</p>
<p>
  All of the startup-behavior is contained in <code>rcS.template</code>.  The
  role of <code>mkromfsimg.sh</code> is to (1) apply the specific configuration
  settings to <code>rcS.template</code> to create the final <code>rcS</code>, and (2) to
  generate the header file <code>nsh_romfsimg.h</code> containg the ROMFS
  file system image.
</p>

patacongo's avatar
patacongo committed
<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="commands"><h1>2.0 Commands</h1></a>
  </td>
  </tr>
</table>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdtest"><h2>2.1 Evaluate Expression (test)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
[ &lt;expression&gt; ]
test &lt;expression&gt;
</pre></ul>
<p>
   <b>Synopsis</b>.
   These are two alternative forms of the same command.  They support
   evaluation of a boolean expression which sets <a href="#builtinvars"><code>$?</code></a>.
   This command is used most frequently as the conditional command following the
   <code>if</code> in the <a href="#conditional"><code>if-then[-else]-fi</code></a> construct.
</p>
<p><b>Expression Syntax:</b></p>
<ul>
  <p>
     expression = simple-expression | !expression | expression -o expression | expression -a expression
  </p>
  <p>
     simple-expression = unary-expression | binary-expression
  </p>
  <p>
     unary-expression = string-unary | file-unary
  </p>
  <p>
     string-unary = -n string | -z string
  </p>
  <p>
     file-unary = -b file | -c file | -d file | -e file | -f file | -r file | -s file | -w file
  </p>
  <p>
     binary-expression = string-binary | numeric-binary
  </p>
  <p>
     string-binary = string = string | string == string | string != string
  </p>
  <p>
     numeric-binary = integer -eq integer | integer -ge integer | integer -gt integer | integer -le integer |
                      integer -lt integer | integer -ne integer
  </p>
</ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdcat"><h2>2.2 Concatenate Files (cat)</h2></a>
  </td>
  </tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
patacongo's avatar
patacongo committed
<ul><pre>
cat <code>&lt;path&gt;</code> [<code>&lt;path&gt;</code> [<code>&lt;path&gt;</code> ...]]
</pre></ul>
<p>
  <b>Synopsis</b>.
  This command copies and concatentates all of the files at <code>&lt;path&gt;</code>
  to the console (or to another file if the output is redirected).
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdcd"><h2>2.3 Change Current Working Directory (cd)</h2></a>
  </td>
  </tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
patacongo's avatar
patacongo committed
<ul><pre>
cd [&lt;dir-path&gt;|-|~|..]
</pre></ul>
<p>
  <b>Synopsis</b>.
  Changes the current working directory (<code>PWD</code>).  Also sets the
  previous working directory environment variable (<code>OLDPWD</code>).
<p>
<p><b>Forms:</b></p>
<ul><table>
  <tr>
    <td><b><code>cd &lt;dir-path&gt;</code></b></td>
    <td>sets the current working directory to <code>&lt;dir-path&gt;</code>.</td>
  </tr>
  <tr>
    <td><b><code>cd -</code></b></td>
    <td>sets the current working directory to the previous
       working directory ($<a href="#environvars"><code>OLDPWD</code></a>).
      Equivalent to <code><a href="#cmdcd">cd</a> $<a href="#environvars">OLDPWD</a></code>.</td>
  </tr>
  <tr>
    <td><b><code>cd</code> or <b><code>cd ~</code></b></td>
    <td>set the current working directory to the 'home'
       directory.  The <i>home</i> directory can be configured by setting
       <code>CONFIG_LIB_HOMEDIR</code> in the configuration file.  The default
       <i>home</i> directory is <code>/</code>.</td>
  </tr>
  <tr>
    <td><b><code>cd ..</code></td>
    <td>sets the current working directory to the parent directory.</td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdcp"><h2>2.4 Copy Files (cp)</h2></a>
  </td>
  </tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
patacongo's avatar
patacongo committed
<ul><pre>
cp &lt;source-path&gt; &lt;dest-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
patacongo's avatar
patacongo committed
  Copy of the contents of the file at <code>&lt;source-path&gt;</code> to the location
  in the filesystem indicated by <code>&lt;dest-path&gt;</code>.
patacongo's avatar
patacongo committed
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmddd"><h2>2.5 Copy and Convert Files (dd)</h2></a>
  </td>
  </tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
patacongo's avatar
patacongo committed
<ul><pre>
dd if=&lt;infile&gt; of=&lt;outfile&gt; [bs=&lt;sectsize&gt;] [count=&lt;sectors&gt;] [skip=&lt;sectors&gt;]
</pre></ul>
<p>
  <b>Synopsis</b>.
  Copy blocks from &lt;infile&gt; to &lt;outfile&gt;.
  &lt;infile&gt; or &lt;outfile&gt; may be the path to a standard file, a character device, or a block device.
  Examples follow:
</p>
<ol>
  <li>
    Read from character device, write to regular file.
    This will create a new file of the specified size filled with zero.
patacongo's avatar
patacongo committed
<ul><pre>
nsh&gt; ls -l /dev
/dev:
 crw-rw-rw-       0 zero
patacongo's avatar
patacongo committed
nsh&gt; dd if=/dev/zero of=/tmp/zeros bs=64 count=16
nsh&gt; ls -l /tmp
/tmp:
 -rw-rw-rw-    1024 ZEROS
</pre></ul>
  </li>
  <li>
    Read from character device, write to block device.
    This will fill the entire block device with zeros.
  </li>
<ul><pre>
nsh&gt; ls -l /dev
/dev:
 brw-rw-rw-       0 ram0
 crw-rw-rw-       0 zero
nsh&gt; dd if=/dev/zero of=/dev/ram0
</pre></ul>
  </li>
  <li>
    Read from a block devic, write to a character device.  This
    will read the entire block device and dump the contents in
    the bit bucket.
  </li>
<ul><pre>
nsh&gt; ls -l /dev
/dev:
 crw-rw-rw-       0 null
 brw-rw-rw-       0 ram0
nsh&gt; dd if=/dev/ram0 of=/dev/null
</pre></ul>
  </li>
</ol>
patacongo's avatar
patacongo committed

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdecho"><h2>2.6 Echo Strings and Variables (echo)</h2></a>
patacongo's avatar
patacongo committed
  </td>
  </tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
patacongo's avatar
patacongo committed
<ul><pre>
echo [&lt;string|$name&gt; [&lt;string|$name&gt;...]]
</pre></ul>
<p>
  <b>Synopsis</b>.
  Copy the sequence of strings and expanded environment variables to
  console output (or to a file if the output is re-directed).
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdexec"><h2>2.7 Execute User Code (exec)</h2></a>
patacongo's avatar
patacongo committed
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
exec &lt;hex-address&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Execute the user logic at address <code>&lt;hex-address&gt;</code>.  NSH will pause
  until the execution unless the user logic is executed in background
  via <code><a href="#cmdexec">exec</a> &lt;hex-address&gt; &amp;</code>.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdexit"><h2>2.8 Exit NSH (exit)</h2></a>
  </td>
  </tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
<ul><pre>
exit
</pre></ul>
<p>
  <b>Synopsis</b>.
  Exit NSH.  Only useful for the serial front end if you have started some other tasks (perhaps
  using the <code><a href="#cmdexec">exec</a></code> command) and you would like to have NSH out of the
  way.  For the telnet front-end, <code>exit</code> terminates the telenet session.

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdfree"><h2>2.9 Show Memory Manager Status (free)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
free
</pre></ul>
<p>
  <b>Synopsis</b>.
  Show the current state of the memory allocator.  For example,
</p>
<ul><pre>
nsh&gt; free
             total       used       free    largest
Mem:       4194288    1591552    2602736    2601584
nsh&gt;
</pre></ul>
<p><b>Where:</b></p>
<ul><table>
  <tr>
    <td><b><code>total</code></b></td>
    <td>This is the total size of memory allocated for use by malloc in bytes.</td>
  </tr>
  <tr>
    <td><b><code>used</code></b></td>
    <td>This is the total size of memory occupied by chunks handed out by malloc.</td>
  </tr>
  <tr>
    <td><b><code>free</code></b></td>
    <td>This is the total size of memory occupied by free (not in use) chunks.</td>
  </tr>
  <tr>
    <td><b><code>largest</code></b></td>
    <td>Size of the largest free (not in use) chunk.</td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdget"><h2>2.10 Get File Via TFTP (get)</h2></a>
patacongo's avatar
patacongo committed
  </td>
  </tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
patacongo's avatar
patacongo committed
<ul><pre>
get [-b|-n] [-f &lt;local-path&gt;] -h &lt;ip-address&gt; &lt;remote-path&gt;
patacongo's avatar
patacongo committed
</pre></ul>
<p>
  <b>Synopsis</b>.
  Copy the file at <code>&lt;remote-address&gt;</code> from the host whose IP address is
  identified by <code>&lt;ip-address&gt;</code>.
patacongo's avatar
patacongo committed
</p>
<p><b>Other options:</b></p>
<ul><table>
  <tr>
    <td><b><code>-f &lt;local-path&gt;</code></b></td>
    <td>
      The file will be saved relative to the current working directory
      unless <code>&lt;local-path&gt;</code> is provided.
    </td>
  </tr>
  <tr>
    <td><b><code>-b|-n</code></b></td>
    <td>
      Selects either binary (&quot;octect&quot;) or test (&quot;netascii&quot;) transfer
      mode.  Default: text.
    </td>
  </tr>
</table></ul>
patacongo's avatar
patacongo committed

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdhelp"><h2>2.11 Show Usage Command Usage (help)</h2></a>
patacongo's avatar
patacongo committed
  </td>
  </tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
patacongo's avatar
patacongo committed
<ul><pre>
help
</pre></ul>
<p>
  <b>Synopsis</b>.
  Presents summary information about each command to console.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdifconfig"><h2>2.12 Show Network Configuration (ifconfig)</h2></a>
patacongo's avatar
patacongo committed
  </td>
  </tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
patacongo's avatar
patacongo committed
<ul><pre>
ifconfig
</pre></ul>
<p>
  <b>Synopsis</b>.
  Show the current configuration of the network, for example:
</p>
<ul><pre>
nsh&gt; ifconfig
eth0    HWaddr 00:18:11:80:10:06
        IPaddr:10.0.0.2 DRaddr:10.0.0.1 Mask:255.255.255.0
</pre></ul>
<p>
  if uIP statistics are enabled (<code>CONFIG_NET_STATISTICS</code>), then
  this command will also show the detailed state of uIP.
</p>