// shelldemo1 - 
// modified scg 6/1/05 - to use tamer shell commands..

#set TITLE = "shelldemo1"
#include top

<center>


<table><tr bgcolor=FFFFFF width=550><td>
<b>1. issue a <tt>date</tt> command and display results..</b><br><br>
<pre>
#shell
   date
#endshell
</pre>
<br>
#set nrows = $shellrowcount()
The above command generated @nrows rows.
</td></tr></table>

<br>
<br>
// The following may be used to set the list of characters considered dangerous..
// #mode   shellmetachars   ;"'`~$\*
<table><tr bgcolor=FFFFFF width=550><td>
<b>2. issue an <tt>echo</tt> command.. show how dangerous metacharacters are automatically filtered out..</b><br><br>
#set BADCHARS = "hello \";'`$ world"
<pre>
#shell
  echo "dangerous characters should not be present here: @BADCHARS"
#endshell
</pre>
</td></tr></table>

<br>
<br>
<table><tr bgcolor=FFFFFF width=550><td>
<b>3. issue a faulty <tt>ls</tt> command.. demonstrate capture of exit code..</b><br><br>
#shell
  ls /flubba_dubba_dub_never
#endshell
#set exitcode = $shellexitcode()
Exit code is @exitcode .
#set nrows = $shellrowcount()
The above command generated @nrows rows.
</td></tr></table>

<br>
<br>
<table><tr bgcolor=FFFFFF width=550>
<td colspan=2>
<b>4. issue a <tt>du</tt> command.. demonstrate capture of result lines ..</b><br><br></td>
</tr>
#shell processrows
  cd /home/groups/q/qu/quisp/htdocs/ 
  du | head -15
#endshell
#while $shellrow( size, path ) == 0 
    <tr bgcolor=FFFFFF><td>@size</td><td><tt>@path</tt></td></tr>
#endloop
#set exitcode = $shellexitcode()
<tr><td colspan=2>
Exit code is @exitcode .
#set nrows = $shellrowcount()
The above command generated @nrows rows.
</td></tr>
</table>

<br>
<br>
<table><tr bgcolor=FFFFFF width=550>
<td colspan=2>
<b>5. issue an ls -l command and demonstrate capture of entire result lines ..</b><br><br></td>
</tr>
#shell processrows
  cd /home/groups/q/qu/quisp/htdocs/live_demo/pages
  ls -l | head -15
#endshell
#call $shellfielddelim( line )
#while $shellrow( psline ) == 0 
    <tr bgcolor=FFFFFF><td><tt>@psline</tt></td></tr>
#endloop
#set exitcode = $shellexitcode()
<tr><td colspan=2>
Exit code is @exitcode .
#set nrows = $shellrowcount()
The above command generated @nrows rows.
</td></tr>
</table>

<br><br>
<h3><a href="@CGIPROG?rtn=index">Back to examples index</a></h3>


</center>

