Code Extracts


Code extracts are integral parts of this book. You'll find lots of them, showing you what to type and the results you'll see. Try them for yourself, and try your own variations; it's all good practice.

To help you, the following conventions are employed, illustrated by this code extract.

$ sudo renice -15 25132 Password: $ ps -xc -O pri,nice | grep iPhoto   PID PRI   NI   TT   STAT     TIME COMMAND 25132  18  -15   ??   S< 0:04.72 iPhoto


The $ symbol is the shell's prompt; don't type it or the space that follows. Type what's shown in the bold fixed-width typeface. Press Return when you complete each line. The response you get back (if any) follows, shown in fixed-width typeface but not bold. In this example, you type two commands, sudo renice -15 25132 and ps -xc -O pri,nice | grep iPhoto, pressing Return at the end of each command.

Sometimes you're required to give your administrator's password before a command can be executed, as shown on the second line of the example. Type your password and press Return, and don't worry when nothing is echoed back as you type. If you are not an administrator, you won't be able to issue such commands.

The output from a command is included in the code extract unless the command line is being illustrated without the need for example output. Sometimes a $ is shown at the end of the results to emphasize that no (more) output is expected. Sometimes the prompt is shown as # which means you should be running as the root user (superuser).

Mostly, output shown in the examples is as you see it in the Terminal. Sometimes it's curtailed, or sections are chopped from the middle, because it's too long and not of great interest.

The book uses an ellipsis (...) to indicated omitted output.

$  top  -o  cpu ... PID  COMMAND    %CPU   TIME    #TH  #PRTS #MREGS RPRVT  ... 15931  top       26.4%  0:29.98     1    18    22  1.04M... 14631  Microsoft 20.5%  6:00:56     4    96   368  23.2M... 10898  Terminal   7.3% 20:17.01     8   105   193  3.37M... 14140  Safari     1.3% 38:12.23     7   291   412  24.0M...    69  WindowServ 1.3%  4:29:47     2   882  2914  34.8M... ...


A Terminal window is usually 80 or more characters wide, but typographical limitations mean that examples in the book are only 60 characters wide. It has been necessary, therefore, to edit long lines by using any of four techniques. Where possible, padding (white space) is removed, so the output shown in the book looks more squashed than you'd see in the Terminal. Sometimes lines are truncated, indicated by an ellipsis.

$ top Processes: 125 total, 3 running, 122 sleeping, 391 thre... Load Avg:  0.93, 0.62, 0.46     CPU usage:  24.7% user,...


Sometimes the middle part is chopped because the end is important.

$ ps -acux USER      PID   %CPU %MEM  ... TIME     COMMAND root    18670   11.0  0.1  ... 0:00.29  sshd saruman 10898    8.5  1.5  ... 22:58.57 Terminal


Finally, sometimes output is wrapped to cover two lines where you'd see it all on one line in the Terminal.

Commands that you type should be on a single line. Where command lines are too long for the width of the book, they are shown broken, but they must be entered as one line. Where a command line has to be broken for layout reasons, the special symbol ¬ is used, and the rest of the command follows on the next line, indented four spaces.

$ ipfw add 3010 allow tcp from any to any dst ¬     1024-65535 in


It's very important to note whether a space appears before the ¬ symbol and to include it on your command line. Type the line shown above as

ipfw add 3010 allow tcp from any to any dst 1024-65535 in


Where no space should be typed, none is shown before the ¬ symbol. For example, type the following line

$ ditto -rsrc User\ Template/¬     English.lproj/ /Users/jan


as:

ditto -rsrc User\ Template/English.lproj/ /Users/jan


In the main text, command names, arguments, options, files, directory names, and whatever you type at the command line is shown in fixed-width typeface.




Mac OS X UNIX 101 Byte-Sized Projects
Mac OS X Unix 101 Byte-Sized Projects
ISBN: 0321374118
EAN: 2147483647
Year: 2003
Pages: 153
Authors: Adrian Mayo

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net