288 Chapter 7
Integrating Programs In Other Languages
Using a System Command
7. Run the program. It should look like Figure 7-4.
Figure 7-4. Listing the Files in a Directory (UNIX)
Listing the Files in a Directory Using a Shell
This variation of the last exercise uses a shell-dependent feature, a pipe (|),
to send the output of one operating system command to another. The second
command will be
wc, which stands for word count. The wc command
counts lines, words, and characters in the named files. The command
wc -l
filename counts the number of lines in the specified file. This example
describes how to count the number of files in a directory, then display the
number and the files.
1. Select
I/O ⇒ Execute Program (UNIX).
a. Set the
Shell field to sh to use the shell features, “|” and “;”.
b. Enter the command,
ls /tmp|wc -l;ls /tmp, in the Shell
command field.
c. Add two data output terminals, one labeled
X and the other labeled
Lines.