diff --git a/ChangeLog b/ChangeLog
index 93b6ce2979cf8424fd1b2291c509da0ef9ef3d49..98ecf7778ca13c2a00e6249b547e0222333ff1dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -395,7 +395,11 @@
 0.3.13 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
 
 	* Added mkfatfs, mkfifo, sleep, usleep and nice commands to NSH
+	* Fixed problem with console input in Cygwin-based simulator; NSH now works
+	  with simulator.
 	* NSH will now execute commands in background
 	* sched_get_priority_max/min returned error on SCHED_RR
 	* Removed duplicate getenv() implementation in /lib
+	* Correct detection of End-of-File in fgets
+	* Implement sh and crude script handler in NSH
 
diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html
index 93cf94966a7aebba727fddf69095b8962bc356af..6356422c5c716fd04e3ab1ec68e1c5c3738a5b13 100644
--- a/Documentation/NuttX.html
+++ b/Documentation/NuttX.html
@@ -8,7 +8,7 @@
   <tr align="center" bgcolor="#e4e4e4">
     <td>
       <h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
-      <p>Last Updated: August 10, 2008</p>
+      <p>Last Updated: August 12, 2008</p>
     </td>
   </tr>
 </table>
@@ -1029,9 +1029,13 @@ buildroot-0.1.0 2007-03-09 &lt;spudmonkey@racsa.co.cr&gt
 nuttx-0.3.13 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
 
 	* Added mkfatfs, mkfifo, sleep, usleep and nice commands to NSH
+	* Fixed problem with console input in Cygwin-based simulator; NSH now works
+	  with simulator.
 	* NSH will now execute commands in background
 	* sched_get_priority_max/min returned error on SCHED_RR
 	* Removed duplicate getenv() implementation in /lib
+	* Correct detection of End-of-File in fgets
+	* Implement sh and crude script handler in NSH
 
 pascal-0.1.3 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
 
diff --git a/examples/README.txt b/examples/README.txt
index 07a3f9d5431f790467c0114d8f0b05d8ea681c7c..3dd7f14947580a3235af3f4b5461ba6aee8596b3 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -66,7 +66,8 @@ examples/nsh
       very large and will not be used unless this setting is 'y'
 
   * CONFIG_EXAMPLES_NSH_LINELEN
-      The maximum length of one command line.  Default: 80
+      The maximum length of one command line and of one output line.
+      Default: 80
 
   * CONFIG_EXAMPLES_NSH_TELNET
       By default, NSH is configured to use the serial console.
@@ -82,9 +83,6 @@ examples/nsh
       Determines the size of the I/O buffer to use for sending/
       receiving TELNET commands/reponses
 
-  * CONFIG_EXAMPLES_NSH_CMD_SIZE
-      The size of one parsed NSH command
-
   * CONFIG_EXAMPLES_NSH_STACKSIZE
       The stack size to use when spawning new threads as new TELNET
       connections are established.
diff --git a/examples/nsh/nsh.h b/examples/nsh/nsh.h
index a4b9c4160227404ff9c11250556218bfb3da74f4..0cc47274ab356cb80fb993aa1dd8fa339b29c5ef 100644
--- a/examples/nsh/nsh.h
+++ b/examples/nsh/nsh.h
@@ -76,10 +76,6 @@
 # define CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE 512
 #endif
 
-#ifndef CONFIG_EXAMPLES_NSH_CMD_SIZE
-# define CONFIG_EXAMPLES_NSH_CMD_SIZE 40
-#endif
-
 /* As threads are created to handle each request, a stack must be allocated
  * for the thread.  Use a default if the user provided no stacksize.
  */
@@ -119,7 +115,7 @@ extern const char g_fmtcmdoutofmemory[];
 
 /* Message handler */
 
-extern int nsh_parse(FAR void *handle, char *cmdline);
+extern int   nsh_parse(FAR void *handle, char *cmdline);
 
 /* I/O interfaces */
 
@@ -139,6 +135,7 @@ extern int nsh_serialmain(void);
 # define nsh_output(handle, ...) printf(__VA_ARGS__)
 
 #endif
+extern char *nsh_linebuffer(FAR void *handle);
 
 /* Shell command handlers */
 
@@ -151,6 +148,9 @@ extern void cmd_ps(FAR void *handle, int argc, char **argv);
   extern void cmd_cat(FAR void *handle, int argc, char **argv);
   extern void cmd_cp(FAR void *handle, int argc, char **argv);
   extern void cmd_ls(FAR void *handle, int argc, char **argv);
+# if CONFIG_NFILE_STREAMS > 0
+  extern void cmd_sh(FAR void *handle, int argc, char **argv);
+# endif  /* CONFIG_NFILE_STREAMS */
 # ifndef CONFIG_DISABLE_MOUNTPOINT
     extern void cmd_mkdir(FAR void *handle, int argc, char **argv);
     extern void cmd_mkfifo(FAR void *handle, int argc, char **argv);
diff --git a/examples/nsh/nsh_fscmds.c b/examples/nsh/nsh_fscmds.c
index 2cfb240982ed9a9fdee1562c16d73961b5513a42..7650c81449629a8f68b91a00061229174abd50ce 100644
--- a/examples/nsh/nsh_fscmds.c
+++ b/examples/nsh/nsh_fscmds.c
@@ -742,7 +742,7 @@ void cmd_rm(FAR void *handle, int argc, char **argv)
 #endif
 
 /****************************************************************************
- * Name: cmd_rm
+ * Name: cmd_rmdir
  ****************************************************************************/
 
 #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0
@@ -755,6 +755,51 @@ void cmd_rmdir(FAR void *handle, int argc, char **argv)
 }
 #endif
 
+/****************************************************************************
+ * Name: cmd_sh
+ ****************************************************************************/
+
+#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
+void cmd_sh(FAR void *handle, int argc, char **argv)
+{
+  FILE *stream;
+  char *buffer;
+  char *pret;
+
+  /* Get a reference to the common input buffer */
+
+  buffer = nsh_linebuffer(handle);
+  if (buffer)
+    {
+      stream = fopen(argv[1], "r");
+      if (!stream)
+        {
+          nsh_output(handle, g_fmtcmdfailed, argv[0], "fopen", NSH_ERRNO);
+          return;
+        }
+
+      do
+        {
+          /* Get the next line of input from the file*/
+
+          fflush(stdout);
+          pret = fgets(buffer, CONFIG_EXAMPLES_NSH_LINELEN, stream);
+          if (pret)
+            {
+              /* Parse process the command.  NOTE:  this is recursive...
+               * we got to cmd_sh via a call to nsh_parse.  So some
+               * considerable amount of stack may be used.
+               */
+
+              (void)nsh_parse(handle, buffer);
+            }
+        }
+      while(pret);
+      fclose(stream);
+    }
+}
+#endif
+
 /****************************************************************************
  * Name: cmd_umount
  ****************************************************************************/
diff --git a/examples/nsh/nsh_main.c b/examples/nsh/nsh_main.c
index 4f6b6245428cca70a183e9f484037db0d4b3fa78..785062bc560dc2ee3426881fd8b9c66505c8e6d6 100644
--- a/examples/nsh/nsh_main.c
+++ b/examples/nsh/nsh_main.c
@@ -116,6 +116,9 @@ static const struct cmdmap_s g_cmdmap[] =
   { "rm",       cmd_rm,       2, 2, "<file-path>" },
   { "rmdir",    cmd_rmdir,    2, 2, "<dir-path>" },
 #endif
+#if  CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
+  { "sh",       cmd_sh,       2, 2, "<script-path>" },
+# endif  /* CONFIG_NFILE_STREAMS */
 #ifndef CONFIG_DISABLE_SIGNALS
   { "sleep",    cmd_sleep,    2, 2, "<sec>" },
 #endif /* CONFIG_DISABLE_SIGNALS */
diff --git a/examples/nsh/nsh_serial.c b/examples/nsh/nsh_serial.c
index ad8ccad1783dd3ad6a94a91d2b10536f2dec8348..5052109d2c3039a5370886da1af4c8054748dab2 100644
--- a/examples/nsh/nsh_serial.c
+++ b/examples/nsh/nsh_serial.c
@@ -71,7 +71,7 @@ struct cmdmap_s
  * Private Data
  ****************************************************************************/
 
-static char line[CONFIG_EXAMPLES_NSH_LINELEN];
+static char g_line[CONFIG_EXAMPLES_NSH_LINELEN];
 
 /****************************************************************************
  * Public Data
@@ -103,15 +103,29 @@ int nsh_serialmain(void)
 
       /* Get the next line of input */
 
-      fgets(line, CONFIG_EXAMPLES_NSH_LINELEN, stdin);
+      if (fgets(g_line, CONFIG_EXAMPLES_NSH_LINELEN, stdin))
+        {
+          /* Parse process the command */
 
-      /* Parse process the command */
-
-      (void)nsh_parse(NULL, line);
-      fflush(stdout);
+          (void)nsh_parse(NULL, g_line);
+          fflush(stdout);
+        }
     }
 }
 
+/****************************************************************************
+ * Name: nsh_linebuffer
+ *
+ * Description:
+ *   Return a reference to the current line buffer
+ *
+ ****************************************************************************/
+
+extern char *nsh_linebuffer(FAR void *handle)
+{
+  return g_line;
+}
+
 /****************************************************************************
  * Name: cmd_exit
  *
diff --git a/examples/nsh/nsh_telnetd.c b/examples/nsh/nsh_telnetd.c
index 872390d5f86c6117ad28e39f1516fd2980c8fcdd..0dbf6b18bbb2a9e4f66446991c2194e26fe1fcbf 100644
--- a/examples/nsh/nsh_telnetd.c
+++ b/examples/nsh/nsh_telnetd.c
@@ -90,7 +90,7 @@ struct telnetd_s
   uint8  tn_bufndx;
   uint8  tn_state;
   char   tn_iobuffer[CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE];
-  char   tn_cmd[CONFIG_EXAMPLES_NSH_CMD_SIZE];
+  char   tn_cmd[CONFIG_EXAMPLES_NSH_LINELEN];
 };
 
 /****************************************************************************
@@ -170,7 +170,7 @@ static void nsh_putchar(struct telnetd_s *pstate, uint8 ch)
 
   /* If a newline was added or if the buffer is full, then process it now */
 
-  if (ch == ISO_nl || pstate->tn_bufndx == (CONFIG_EXAMPLES_NSH_CMD_SIZE - 1))
+  if (ch == ISO_nl || pstate->tn_bufndx == (CONFIG_EXAMPLES_NSH_LINELEN - 1))
     {
       if (pstate->tn_bufndx > 0)
         {
@@ -550,6 +550,20 @@ int nsh_telnetout(FAR void *handle, const char *fmt, ...)
   return len;
 }
 
+/****************************************************************************
+ * Name: nsh_linebuffer
+ *
+ * Description:
+ *   Return a reference to the current line buffer
+ *
+ ****************************************************************************/
+
+extern char *nsh_linebuffer(FAR void *handle)
+{
+  struct telnetd_s *pstate = (struct telnetd_s *)handle;
+  return pstate->tn_cmd;
+}
+
 /****************************************************************************
  * Name: cmd_exit
  *