Skip to content
Snippets Groups Projects
NuttShell.html 68.4 KiB
Newer Older
patacongo's avatar
patacongo committed

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdkill"><h2>2.13 Send a signal to a task (kill)</h2></a>
patacongo's avatar
patacongo committed
  </td>
  </tr>
</table>

<ul><pre>
kill -&lt;signal&gt; &lt;pid&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Send the &lt;signal&gt; to the task identified by &lt;pid&gt;.
patacongo's avatar
patacongo committed
</p>
<ul><pre>
nsh&gt; mkfifo /dev/fifo
nsh&gt; cat /dev/fifo &
cat [2:128]
nsh&gt; ps
PID   PRI SCHD TYPE   NP STATE    NAME
    0   0 FIFO TASK      READY    Idle Task()
    1 128 FIFO TASK      RUNNING  init()
    2 128 FIFO PTHREAD   WAITSEM  <pthread>(51ea50)
nsh&gt; kill -9 2
nsh: cat: open failed: 4
nsh&gt; ps
PID   PRI SCHD TYPE   NP STATE    NAME
    0   0 FIFO TASK      READY    Idle Task()
    1 128 FIFO TASK      RUNNING  init()
nsh&gt;
</pre></ul>
<p><small>
  <b>NOTE</b>:
  NuttX does not support a FULL POSIX signalling system.
  Standard signals like SIGCHLD, SIGINTR, SIGKILL, etc. do not exist in NuttX and sending those signal may not have the result that you expect.
  Rather, NuttX supports only what are referred to as POSIX real-time signals.
  These signals may be used to communicate with running tasks, may be use to waiting waiting tasks, etc.
  But, as an example, <code>kill -9</code> (SIGKILL) will not terminate a task.
</p></small>
patacongo's avatar
patacongo committed

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdlosetup"><h2>2.14 Setup/teardown the Loop Device (losetup)</h2></a>
patacongo's avatar
patacongo committed
  </td>
  </tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax 1:</b></p>
patacongo's avatar
patacongo committed
<ul><pre>
losetup [-o <offset>] [-r] &lt;dev-path&gt; &lt;file-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
patacongo's avatar
patacongo committed
   Setup the loop device at &lt;dev-path&gt; to access the file at &lt;file-path&gt; as a block device.
patacongo's avatar
patacongo committed
   In the following example a 256Kb file is created (<code>dd</code>) and <code>losetup</code> is
   used to make the file accessible as a block device. 
   A FAT file system is created (<code>mkfatfs</code>) and mounted (<code>mount</code>).
   Files can then be managed on the loop-mounted file.
patacongo's avatar
patacongo committed
<ul><pre>
nsh&gt; dd if=/dev/zero of=/tmp/image bs=512 count=512
nsh&gt; ls -l /tmp
/tmp:
 -rw-rw-rw-   262144 IMAGE
nsh&gt; losetup /dev/loop0 /tmp/image
nsh&gt; ls -l /dev
/dev:
 brw-rw-rw-       0 loop0
nsh&gt; mkfatfs /dev/loop0
nsh&gt; mount -t vfat /dev/loop0 /mnt/example
nsh&gt; ls -l /mnt
ls -l /mnt
/mnt:
 drw-rw-rw-       0 example/
patacongo's avatar
patacongo committed
nsh&gt; echo &quot;This is a test&quot; &gt;/mnt/example/atest.txt
nsh&gt; ls -l /mnt/example
/mnt/example:
 -rw-rw-rw-      16 ATEST.TXT
nsh&gt; cat /mnt/example/atest.txt
This is a test
nsh&gt;
patacongo's avatar
patacongo committed
</pre></ul>
patacongo's avatar
patacongo committed
</p>

patacongo's avatar
patacongo committed
<p><b>Command Syntax 2:</b></p>
patacongo's avatar
patacongo committed
<ul><pre>
losetup d &lt;dev-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Teardown the setup for the loop device at &lt;dev-path&gt;.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdls"><h2>2.15 List Directory Contents (ls)</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>
ls [-lRs] &lt;dir-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Show the contents of the directory at <code>&lt;dir-path&gt;</code>.  NOTE:
  <code>&lt;dir-path&gt;</code> must refer to a directory and no other filesystem
  object.
</p>
<p><b>Options:</b></p>
<ul><table>
  <tr>
    <td><b><code>-R</code></b></td>
    <td>Show the constents of specified directory and all of its
        sub-directories.</td>
  </tr>
  <tr>
    <td><b><code>-s</code></b></td>
    <td>Show the size of the files along with the filenames in the
        listing</td>
  </tr>
  <tr>
    <td><b><code>-l</code></b></td>
    <td>Show size and mode information along with the filenames
        in the listing.</td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdmbhw"><h2>2.16 Access Memory (mb, mh, and mw)</h2></a>
patacongo's avatar
patacongo committed
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
mb &lt;hex-address&gt;[=&lt;hex-value&gt;][ &lt;hex-byte-count&gt;]
mh &lt;hex-address&gt;[=&lt;hex-value&gt;][ &lt;hex-byte-count&gt;]
mw &lt;hex-address&gt;[=&lt;hex-value&gt;][ &lt;hex-byte-count&gt;]
</pre></ul>
<p>
  <b>Synopsis</b>.
  Access memory using byte size access (mb), 16-bit accesses (mh),
  or 32-bit access (mw).  In each case,
</p>
<ul><table>
  <tr>
    <td><code>&lt;hex-address&gt;</code>.</td>
    <td>Specifies the address to be accessed.  The current
      value at that address will always be read and displayed.
  </tr>
  <tr>
    <td><code>&lt;hex-address&gt;=&lt;hex-value&gt;</code>.</td>
    <td>Read the value, then write <code>&lt;hex-value&gt;</code>
      to the location.
  </tr>
  <tr>
    <td><code>&lt;hex-byte-count&gt;</code>.</td>
    <td>Perform the mb, mh, or mw operation on a total
      of <code>&lt;hex-byte-count&gt;</code> bytes, increment the <code>&lt;hex-address&gt;</code> appropriately
      after each access
  </tr>
</table></ul>
<p><b>Example:</b><p>
<ul><pre>
nsh&gt; mh 0 16
  0 = 0x0c1e
  2 = 0x0100
  4 = 0x0c1e
  6 = 0x0110
  8 = 0x0c1e
  a = 0x0120
  c = 0x0c1e
  e = 0x0130
  10 = 0x0c1e
  12 = 0x0140
  14 = 0x0c1e
nsh&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdps"><h2>2.17 Show Current Tasks and Threads (ps)</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>
ps
</pre></ul>
<p>
  <b>Synopsis</b>.
  Show the currently active threads and tasks.  For example,
</p>
<ul><pre>
nsh&gt; ps
PID   PRI SCHD TYPE   NP STATE    NAME
    0   0 FIFO TASK      READY    Idle Task()
    1 128 RR   TASK      RUNNING  init()
    2 128 FIFO TASK      WAITSEM  nsh_telnetmain()
    3 100 RR   PTHREAD   WAITSEM  &lt;pthread&gt;(21)
nsh&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdmkdir"><h2>2.18 Create a Directory (mkdir)</h2></a>
patacongo's avatar
patacongo committed
  </td>
</tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
<ul><pre>
mkdir &lt;path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Create the directory at <code>&lt;path&gt;</code>.
  All components of of <code>&lt;path&gt;</code> except the final directory name must exist on a mounted file
  system; the final directory must not.
</p>
<p>
  <b>Limited to Mounted File Systems</b>.
  Recall that NuttX uses a <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> for its root file
  system.
  The <code>mkdir</code> command can only be used to create directories in volumes set up with the
  <a href="#cmdmount"><code>mount</code></a> command; it cannot be used to create directories in the <i>pseudo</i> filesystem.
</p>
<p><b>Example:</b></p>
<ul><pre>
nsh> mkdir /mnt/fs/tmp
nsh> ls -l /mnt/fs
/mnt/fs:
 drw-rw-rw-       0 TESTDIR/
 drw-rw-rw-       0 TMP/
nsh>
</pre></ul>

patacongo's avatar
patacongo committed
<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdmkfatfs"><h2>2.19 Create a FAT Filesystem (mkfatfs)</h2></a>
patacongo's avatar
patacongo committed
  </td>
</tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
<ul><pre>
mkfatfs &lt;path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Format a fat file system on the block device specified by <code>&lt;path&gt;</code>.
  NSH provides this command to access the <a href="mkfatfs"><code>mkfatfs()</code></a> NuttX API.
  This block device must reside in the NuttX <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> and
  must have been created by some call to <code>register_blockdriver()</code> (see <code>include/nuttx/fs.h</code>).
</p>

patacongo's avatar
patacongo committed
<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdmkfifo"><h2>2.20 Create a FIFO (mkfifo)</h2></a>
patacongo's avatar
patacongo committed
  </td>
</tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
<ul><pre>
mkfifo &lt;path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Creates a FIFO character device anywhere in the pseudo file system, creating
  whatever psuedo directories that may be needed to complete the <code>&lt;path&gt;</code>.
  By convention, however, device drivers are place in the standard <code>/dev</code> directory.
  After it is created, the FIFO device may be used as any other device driver.
  NSH provides this command to access the <a href="NuttxUserGuide.html#mkfifo"><code>mkfifo()</code></a> NuttX API.
</p>
<p><b>Example</b></p>
<ul><pre>
nsh> ls -l /dev
/dev:
 crw-rw-rw-       0 console
 crw-rw-rw-       0 null
 brw-rw-rw-       0 ram0
nsh> mkfifo /dev/fifo
nsh> ls -l /dev
ls -l /dev
/dev:
 crw-rw-rw-       0 console
 crw-rw-rw-       0 fifo
 crw-rw-rw-       0 null
 brw-rw-rw-       0 ram0
nsh>
</pre></ul>

patacongo's avatar
patacongo committed
<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdmkrd"><h2>2.21 Create a RAMDISK (mkrd)</h2></a>
  </td>
</tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
mkrd [-m &lt;minor&gt;] [-s &lt;sector-size&gt;] &lt;nsectors&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Create a ramdisk consisting of <code>&lt;nsectors&gt;</code>, each of size
  <code>&lt;sector-size&gt;</code> (or 512 bytes if <code>&lt;sector-size&gt;</code> is not specified.
  The ramdisk will be registered as <code>/dev/ram&lt;n&gt;</code> (if <code>&lt;n&gt;</code> is not
  specified, mkrd will attempt to register the ramdisk as <code>/dev/ram0</code>.
</p>
<p><b>Example</b></p>
<ul><pre>
nsh&gt; ls /dev
/dev:
 console
 null
 ttyS0
 ttyS1
nsh&gt; mkrd 1024
nsh&gt; ls /dev
/dev:
 console
 null
 ram0
 ttyS0
 ttyS1
nsh&gt;
</pre></ul>
<p>
  Once the ramdisk has been created, it may be formatted using
  the <code>mkfatfs</code> command and mounted using the <code>mount</code> command.
</p>
<p><b>Example</b></p>
<ul><pre>
nsh&gt; mkrd 1024
nsh&gt; mkfatfs /dev/ram0
nsh&gt; mount -t vfat /dev/ram0 /tmp
nsh&gt; ls /tmp
/tmp:
nsh&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdmount"><h2>2.22 Mount a File System (mount)</h2></a>
patacongo's avatar
patacongo committed
  </td>
</tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
<ul><pre>
mount -t &lt;fstype&gt; &lt;block-device&gt; <code>&lt;dir-path&gt;</code>
</pre></ul>
<p>
  <b>Synopsis</b>.
  The 'm  ount' command mounts a file system in the NuttX psuedo
  filesystem.  'mount' performs a three way associating, binding:
</p>
<ol>
  <li><b>File system.</b>
    The '-t <code>&lt;fstype&gt;</code>' option identifies the type of
    file system that has been formatted on the <code>&lt;block-device&gt;</code>.
    As of this writing, <code>vfat</code> is the only supported value for <code>&lt;fstype&gt;</code>
  </li>
  <li><b>Block Device.</b>
    The <code>&lt;block-device&gt;</code> argument is the full or relative
    path to a block driver inode in the <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a>.
    By convention, this is a name under the <code>/dev</code> sub-directory.
    This <code>&lt;block-device&gt;</code>  must have been previously formatted with the same file system
    type as specified by <code>&lt;fstype&gt;</code>
  </li>
  <li><b>Mount Point.</b>
    The mount point, <code>&lt;dir-path&gt;</code>, is the location in the
    <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> where the mounted volume will appear.
    This mount point can only reside in the NuttX <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a>.
    By convention, this mount point is a subdirectory under <code>/mnt</code>.
    The mount command will create whatever psuedo directories that may be needed to complete the
    full path but the full path must not already exist.
  </li>
</ol>
<p>
  After the volume has been mounted in the NuttX
patacongo's avatar
patacongo committed
  <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a>,
  it may be access in the same way as other objects in thefile system.
</p>
<p><b>Example</b></p>
<ul><pre>
nsh> ls -l /dev
/dev:
 crw-rw-rw-       0 console
 crw-rw-rw-       0 null
 brw-rw-rw-       0 ram0
nsh> ls /mnt
nsh: ls: no such directory: /mnt
nsh> mount -t vfat /dev/ram0 /mnt/fs
nsh> ls -l /mnt/fs/testdir
/mnt/fs/testdir:
 -rw-rw-rw-      15 TESTFILE.TXT
nsh> echo "This is a test" >/mnt/fs/testdir/example.txt
nsh> ls -l /mnt/fs/testdir
/mnt/fs/testdir:
-rw-rw-rw-      15 TESTFILE.TXT
 -rw-rw-rw-      16 EXAMPLE.TXT
nsh> cat /mnt/fs/testdir/example.txt
This is a test
nsh>
</pre></ul>

patacongo's avatar
patacongo committed
<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdping"><h2>2.23 Check Network Peer (ping)</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>
ping [-c &lt;count&gt;] [-i &lt;interval&gt;] &lt;ip-address&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Test the network communication with a remote peer.  Example,
</p>
<ul><pre>
nsh&gt; 10.0.0.1
PING 10.0.0.1 56 bytes of data
56 bytes from 10.0.0.1: icmp_seq=1 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=2 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=3 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=4 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=5 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=6 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=7 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=8 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=9 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=10 time=0 ms
10 packets transmitted, 10 received, 0% packet loss, time 10190 ms
nsh&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdput"><h2>2.24 Send File Via TFTP (put)</h2></a>
  </td>
  </tr>
</table>

patacongo's avatar
patacongo committed
<p><b>Command Syntax:</b></p>
<ul><pre>
put [-b|-n] [-f &lt;remote-path&gt;] -h &lt;ip-address&gt; &lt;local-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Copy the file at <code>&lt;local-address&gt;</code> to the host whose IP address is
  identified by <code>&lt;ip-address&gt;</code>.
</p>
<p><b>Other options:</b></p>
<ul><table>
  <tr>
    <td><b><code>-f &lt;remote-path&gt;</code></b></td>
    <td>
      The file will be saved relative with the same name on the host
      unless <code>&lt;remote-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>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdpwd"><h2>2.25 Show Current Working Directory (pwd)</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>
pwd
</pre></ul>
<p>
  <b>Synopsis</b>.
  Show the current working directory.
</p>
<ul><pre>
nsh&gt; cd /dev
nsh&gt; pwd
/dev
nsh&gt;
</pre></ul>

<p>Same as <code><a href="#cmdecho">echo</a> <a href="#environvars">$PWD</a></code>.</p>
<ul><pre>
nsh&gt; echo $PWD
/dev
nsh&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdrm"><h2>2.26 Remove a File (rm)</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>
rm &lt;file-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Remove the specified <code>&lt;file-path&gt;</code> name from the mounted file system.
  Recall that NuttX uses a <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> for its root file
  system.
  The <code>rm</code> command can only be used to remove (unlink) files in volumes set up with the
  <a href="#cmdmount"><code>mount</code></a> command;
  it cannot be used to remove names in the <i>pseudo</i> filesystem.
</p>
<p><b>Example:</b></p>
<ul><pre>
nsh> ls /mnt/fs/testdir
/mnt/fs/testdir:
 TESTFILE.TXT
 EXAMPLE.TXT
nsh> rm /mnt/fs/testdir/example.txt
nsh> ls /mnt/fs/testdir
/mnt/fs/testdir:
 TESTFILE.TXT
nsh>
</pre></ul>

patacongo's avatar
patacongo committed
<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdrmdir"><h2>2.27 Remove a Directory (rmdir)</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>
rmdir &lt;dir-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Remove the specified <code>&lt;dir-path&gt;</code> directory from the mounted file system.
  Recall that NuttX uses a <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> for its root file
  system.
  The <code>rmdir</code> command can only be used to remove directories from volumes set up with the
  <a href="#cmdmount"><code>mount</code></a> command;
  it cannot be used to remove directories from the <i>pseudo</i> filesystem.
</p>
<p><b>Example:</b></p>
<ul><pre>
nsh> mkdir /mnt/fs/tmp
nsh> ls -l /mnt/fs
/mnt/fs:
 drw-rw-rw-       0 TESTDIR/
 drw-rw-rw-       0 TMP/
nsh> rmdir /mnt/fs/tmp
nsh> ls -l /mnt/fs
/mnt/fs:
 drw-rw-rw-       0 TESTDIR/
nsh>
</pre></ul>

patacongo's avatar
patacongo committed
<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdset"><h2>2.28 Set an Environment Variable (set)</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>
set &lt;name&gt; &lt;value&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Set the environment variable <code>&lt;name&gt;</code> to the string <code>&lt;value&gt;</code>.
  For example,
</p>
<ul><pre>
nsh&gt; echo $foobar

nsh&gt; set foobar foovalue
nsh&gt; echo $foobar
foovalue
nsh&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdsh"><h2>2.29 Execute an NSH Script (sh)</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>
sh &lt;script-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Execute the sequence of NSH commands in the file referred
  to by <code>&lt;script-path&gt;.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdsleep"><h2>2.30 Wait for Seconds (sleep)</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>
sleep &lt;sec&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Pause execution (sleep) for <code>&lt;sec&gt;</code> seconds.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdunmount"><h2>2.31 Unmount a File System (umount)</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>
umount &lt;dir-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Un-mount the file system at mount point <code>&lt;dir-path&gt;</code>.
  The <code>umount</code> command can only be used to un-mount volumes previously mounted using
  <a href="#cmdmount"><code>mount</code></a> command.
</p>
<p><b>Example:</b></p>
<ul><pre>
nsh> ls /mnt/fs
/mnt/fs:
 TESTDIR/
nsh> umount /mnt/fs
nsh> ls /mnt/fs
/mnt/fs:
nsh: ls: no such directory: /mnt/fs
nsh>
</pre></ul>

patacongo's avatar
patacongo committed
<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdunset"><h2>2.32 Unset an Environment Variable (unset)</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>
unset &lt;name&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Remove the value associated with the environment variable
  <code>&lt;name&gt;.  Example:
</p>
<ul><pre>
nsh&gt; echo $foobar
foovalue
nsh&gt; unset foobar
nsh&gt; echo $foobar

nsh&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdusleep"><h2>2.33 Wait for Microseconds (usleep)</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>
usleep &lt;usec&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Pause execution (sleep) of <code>&lt;usec&gt;</code> microseconds.
</p>

patacongo's avatar
patacongo committed
<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdwget">2.34 Get File Via HTTP (wget)</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>
wget [-o &lt;local-path&gt;] &lt;url&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Use HTTP to copy the file at <code>&lt;url&gt;</code> to the current directory.
</p>
<p><b>Options:</b></p>
<ul><table>
  <tr>
    <td><b><code>-o &lt;local-path&gt;</code></b></td>
    <td>
      The file will be saved relative to the current working directory
      and with the same name as on the HTTP server unless <code>&lt;local-path&gt;</code> is provided.
    </td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
patacongo's avatar
patacongo committed
    <a name="cmdxd"><h2>2.35 Hexadecimal dump (xd)</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>
xd &lt;hex-address&gt; &lt;byte-count&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Dump <code>&lt;byte-count&gt;</code> bytes of data from address <code>&lt;hex-address&gt;</code>.
</p>
<p><b>Example:</b></p>
<ul><pre>
nsh> xd 410e0 512
Hex dump:
0000: 00 00 00 00 9c 9d 03 00 00 00 00 01 11 01 10 06 ................
0010: 12 01 11 01 25 08 13 0b 03 08 1b 08 00 00 02 24 ....%..........$
...
01f0: 08 3a 0b 3b 0b 49 13 00 00 04 13 01 01 13 03 08 .:.;.I..........
nsh>
</pre></ul>

patacongo's avatar
patacongo committed
<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="configuration"><h1>3.0 Configuration Settings</h1></a>
  </td>
  </tr>
</table>

<p>
  The availability of the above commands depends upon features that
  may or may not be enabled in the NuttX configuration file.  The 
  following <a href="#cmddependencies">table</a> indicates the dependency of each command on NuttX
  configuration settings.  General configuration settings are discussed
  in the <a href="NuttxPortingGuide.html">NuttX Porting Guide.</a>
  Configuration settings specific to NSH as discussed at the <a href="#nshconfiguration">bottom</a> of this document.
</p>

<p>
  Note that in addition to general NuttX configuation settings, each NSH command can be
  individually disabled via the settings in the rightmost column.
  All of these settings make the configuration of NSH potentially complex but also allow it to
  squeeze into very small memory footprints.
</p>

patacongo's avatar
patacongo committed
<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmddependencies"><h2>3.1 Command Dependencies on Configuration Settings</h2></a>
  </td>
  </tr>
</table>

<center><p>Table. Command Dependencies on Configuration Settings</p>
<table width="100%">
  <tr bgcolor="#e4e4e4">
    <th align="left" width="25%">Command</th>
    <th align="left">Depends on Configuration</th>
    <th align="left">Can Be Disabled with</th>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>[</code></b></td>
    <td>!<code>CONFIG_EXAMPLES_NSH_DISABLESCRIPT</code></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_TEST</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>cat</code></b></td>
    <td><code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_CAT</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>cd</code></b></td>
patacongo's avatar
patacongo committed
    <td>!<code>CONFIG_DISABLE_ENVIRON</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_CD</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>cp</code></b></td>
    <td><code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_CP</code></td>
patacongo's avatar
patacongo committed
  </tr>
patacongo's avatar
patacongo committed
  <tr>
    <td><b><code>dd</code></b></td>
    <td><code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_DD</code></td>
  </tr>
patacongo's avatar
patacongo committed
  <tr>
    <td><b><code>echo</code></b></td>
    <td><br></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_ECHO</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>exec</code></b></td>
    <td><br></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_EXEC</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>exit</code></b></td>
    <td><br></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_EXIT</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>free</code></b></td>
    <td><br></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_FREE</code></td>
  </tr>
  <tr>
    <td><b><code>get</code></b></td>
patacongo's avatar
patacongo committed
    <td><code>CONFIG_NET</code> &amp;&amp; <code>CONFIG_NET_UDP</code> &amp;&amp;
patacongo's avatar
patacongo committed
        <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_NET_BUFSIZE</code> &gt;= 558<sup>1</sup></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_GET</code></td>
  </tr>
patacongo's avatar
patacongo committed
  <tr>
    <td><b><code>help</code></b></td>
    <td><br></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_HELP</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>ifconfig</code></b></td>
    <td><code>CONFIG_NET</code></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG</code></td>
patacongo's avatar
patacongo committed
  </tr>
patacongo's avatar
patacongo committed
  <tr>
    <td><b><code>kill</code></b></td>
    <td>!<code>CONFIG_DISABLE_SIGNALS</code></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_KILL</code></td>
  </tr>
patacongo's avatar
patacongo committed
  <tr>
    <td><b><code>losetup</code></b></td>
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP</code></td>
  </tr>
patacongo's avatar
patacongo committed
  <tr>
    <td><b><code>ls</code></b></td>
    <td><code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_LS</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>mb,mh,mw</code></b></td>
    <td><br></td>
    <td>
      <code>CONFIG_EXAMPLES_NSH_DISABLE_MB</code>,<br>
      <code>CONFIG_EXAMPLES_NSH_DISABLE_MH</code>,<br>
      <code>CONFIG_EXAMPLES_NSH_DISABLE_MW</code>
    </td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>mkdir</code></b></td>
patacongo's avatar
patacongo committed
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_WRITABLE</code><sup>4</sup></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_MKDIR</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>mkfatfs</code></b></td>
patacongo's avatar
patacongo committed
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_FAT</code></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>mkfifo</code></b></td>
    <td><code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO</code></td>
  </tr>
  <tr>
    <td><b><code>mkrd</code></b></td>
patacongo's avatar
patacongo committed
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_WRITABLE</code><sup>4</sup></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_MKRD</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>mount</code></b></td>
patacongo's avatar
patacongo committed
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_READABLE</code><sup>3</sup></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_MOUNT</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>ping</code></b></td>
patacongo's avatar
patacongo committed
    <td><code>CONFIG_NET</code> &amp;&amp; <code>CONFIG_NET_ICMP</code> &amp;&amp;
        <code>CONFIG_NET_ICMP_PING</code>  &amp;&amp; !<code>CONFIG_DISABLE_CLOCK</code> &amp;&amp;
        !<code>CONFIG_DISABLE_SIGNALS</code></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_PING</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>ps</code></b></td>
    <td><br></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_PS</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>put</code></b></td>
patacongo's avatar
patacongo committed
    <td><code>CONFIG_NET</code> &amp;&amp; <code>CONFIG_NET_UDP</code> &amp;&amp;
patacongo's avatar
patacongo committed
    <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_NET_BUFSIZE</code> &gt;= 558<sup>1,2</sup></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_PUT</code></td>
  </tr>
patacongo's avatar
patacongo committed
  <tr>
    <td><b><code>pwd</code></b></td>
    <td>!<code>CONFIG_DISABLE_ENVIRON</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_PWD</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>rm</code></b></td>
patacongo's avatar
patacongo committed
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_WRITABLE</code><sup>4</sup></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_RM</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>rmdir</code></b></td>
patacongo's avatar
patacongo committed
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_WRITABLE</code><sup>4</sup></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_RMDIR</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>set</code></b></td>
    <td>!<code>CONFIG_DISABLE_ENVIRON</code></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_SET</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>sh</code></b></td>
    <td><code>CONFIG_NFILE_DESCRIPTORS &gt; 0 &amp;&amp; <code>CONFIG_NFILE_STREAMS &gt; 0 &amp;&amp; !<code>CONFIG_EXAMPLES_NSH_DISABLESCRIPT</code></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_SH</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>sleep</code></b></td>
    <td>!<code>CONFIG_DISABLE_SIGNALS</code></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_SLEEP</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>test</code></b></td>
    <td>!<code>CONFIG_EXAMPLES_NSH_DISABLESCRIPT</code></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_TEST</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>umount</code></b></td>
patacongo's avatar
patacongo committed
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_READABLE</code><sup>3</sup></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>unset</code></b></td>
    <td>!<code>CONFIG_DISABLE_ENVIRON</code></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_UNSET</code></td>
patacongo's avatar
patacongo committed
  </tr>
  <tr>
    <td><b><code>usleep</code></b></td>
    <td>!<code>CONFIG_DISABLE_SIGNALS</code></td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_USLEEP</code></td>
  </tr>
patacongo's avatar
patacongo committed
  <tr>
    <td><b><code>wget</code></b></td>
    <td><code>CONFIG_NET</code> &amp;&amp; <code>CONFIG_NET_TCP</code> &amp;&amp;
        <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_WGET</code></td>