diff --git a/LDP/guide/docbook/abs-guide/Change.log b/LDP/guide/docbook/abs-guide/Change.log index 6275fa5b..49e4752e 100644 --- a/LDP/guide/docbook/abs-guide/Change.log +++ b/LDP/guide/docbook/abs-guide/Change.log @@ -6,6 +6,77 @@ http://personal.riverusers.com/~thegrendel/Change.log ------------------------------------------------------------------------ +Version 3.9 +Spiceberry release, 05/15/06 + +1) In the "Starting Off With a Sha-Bang" chapter: + Added footnote that when launching a script from Bash, + the #! isn't strictly necessary. + (Thank you, Diane Holt, for bringing this to my attention.) + +2) In "I/O Redirection" chapter: + At introduction to chapter, + Added explanatory examples in introductory in-line code block. + At "Using Exec" section, + Added brief explanation of different effects of "exec N > filename" and "N > filename." + + (Thank you, Ahmed Darwish, for both of the above.) + +3) In "Special Characters" chapter: + At "$" entry, added an additional usage example. + At "$$" entry, added footnote explaining of what a PID is. + At redirection operators entry, added "<>" description. + At "-" entry, fixup on "bunzip2" example. + (Thanks, Roman.) + +4) In "Miscellaneous Commands" section of "External Commands" chapter: + At "yes" entry, + added parsing of variables. + +5) In "File and Archiving Commands" section of "External Commands" Chapter: + At "gzip" entry, added note about "-c" option. + +6) In "Manipulating Strings" section of "Variables Revisited" chapter: + At "${string%%substring}" entry, + added "ra2ogg.sh" example script. + +7) In "Bash, version 3" section of "Bash, versions 2 and 3" chapter + Added "Bash, version 3.1" subsection. + Entry for "+=" operator. + +8) In "Subshells" chapter: + Modified final note about command list within curly brackets, + per suggestion of Andreas Kühne. + +9) In "Gotchas" chapter: + Converted separate entries to bulleted-item list. + Added entry for error in leaving out termination semicolon in command + block within curly braces. + (Thank you, Andreas Kühne.) + +10) In "Writing Scripts" section of "Exercises" appendix: + Added "Checking whether a process is still running" exercise + ("Easy" section). + +11) "System and Administrative Commands" chapter: + Minor revision of "strace" entry. + Added "ltrace" entry. + Added "lspci" entry. + +12) In "Contributed Scripts" appendix: + Minor modification to "life.sh" script, to check for missing startfile. + +13) In "Reference Cards" appendix: + Fixed up error in "Miscellaneous Constructs" table (terminating + semicolon in command list within curly brackets). + (Thank you, Andreas Kühne.) + +14) In "Revision History" appendix: + Fixed embarrassing typos. + +15) Various minor fixups on example scripts. + + Version 3.8 Blaeberry release, 02/26/06 diff --git a/LDP/guide/docbook/abs-guide/README b/LDP/guide/docbook/abs-guide/README index 919fc248..1636235b 100644 --- a/LDP/guide/docbook/abs-guide/README +++ b/LDP/guide/docbook/abs-guide/README @@ -43,7 +43,7 @@ prepend.sh (lines 18 and 28) array-assign.bash cdll (lines 51-53, 59, 63-69, 82-83, 85, 463, 521, 567-568, 570, 580-586, 637, 656-658) -directory-info.sh (lines 273 and 353) +directory-info.sh (lines 36, 166, 273 and 353) is-spammer.sh (comments on lines 4, 35, and 51) bashrc (comments on lines 596 and 618) commentblock.sh (lines 4 and 23) @@ -52,7 +52,6 @@ self-document2.sh (line 8) dev-tcp.sh (line 14) archiveweblogs.sh (comment in line 4) multiple-processes.sh (line 143) -directory-info.sh (lines 36 and 166) catscripts.sh (lines 12 and 21) is_spammer.bash (comments on various lines) iscan.sh (comment in line 10) @@ -62,3 +61,4 @@ hash-example.sh (comment in line 3: < --> <, > --> >) quote-fetch.sh (comment in line 26: & --> &) ftpget.sh (comment in line 28) whx.sh (comment in line 259) +In-line code block at beginning of "I/O Redirection" chapter, line 41. diff --git a/LDP/guide/docbook/abs-guide/abs-guide.sgml b/LDP/guide/docbook/abs-guide/abs-guide.sgml index b6f05afa..da531679 100644 --- a/LDP/guide/docbook/abs-guide/abs-guide.sgml +++ b/LDP/guide/docbook/abs-guide/abs-guide.sgml @@ -321,6 +321,7 @@ Uncomment line below to generate index. + @@ -350,19 +351,12 @@ Uncomment line below to generate index. - 3.8 - 26 February 2006 + 3.9 + 15 May 2006 - - 3.6 - 28 Aug 2005 - mc - 'POKEBERRY' release: Bugfix Update. - - 3.7 23 Oct 2005 @@ -377,6 +371,13 @@ Uncomment line below to generate index. 'BLAEBERRY' release: Minor Update. + + 3.9 + 15 May 2006 + mc + 'SPICEBERRY' release: Minor Update. + + @@ -397,7 +398,7 @@ Uncomment line below to generate index. introduction to programming concepts. + url="http://personal.riverusers.com/~thegrendel/abs-guide-3.9.tar.bz2"> The latest update of this document, as an archived, bzip2-ed tarball including both the SGML source and rendered HTML, may @@ -761,6 +762,11 @@ exit $WHATEVER # Doesn't matter. The script will not exit here.#!, since the variable assignment line, lines=50, uses a shell-specific construct. + If Bash is your default shell, then the + #! isn't necessary at the beginning of a script. + However, if launching a script from a different shell, such as + tcsh, then you will + need the #!. Note again that #!/bin/sh invokes the default shell interpreter, which defaults to /bin/bash on a Linux machine. @@ -1672,7 +1678,7 @@ echo $var2 # 23skidoo - $$ + $$ $$ @@ -1690,8 +1696,15 @@ echo $var2 # 23skidoo process ID variable The $$ variable - holds the process ID of the script in - which it appears. + holds the process ID + + A PID, or + process ID, is a number assigned + to a running process. The PIDs + of running processes may be viewed with a ps command. + + of the script in which it appears. @@ -1790,11 +1803,12 @@ cp file22.{txt,backup} Block of code [curly brackets] - Also referred to as an inline group, - this construct, in effect, creates an anonymous - function. However, unlike a Also referred to as an inline group, + this construct, in effect, creates an anonymous + function (a function without a + name). However, unlike in a standard function, the variables - in a code block remain visible to the remainder of the + inside a code block remain visible to the remainder of the script. bash$ { local a; @@ -1974,7 +1988,7 @@ echo ${Array[1]} - > &> >& >> < + > &> >& >> < <> > @@ -2026,10 +2040,17 @@ echo ${Array[1]} to stderr. scriptname >>filename appends - the output of scriptname - to file filename. If - filename does not already exist, - it will be created. + the output of scriptname + to file filename. If + filename does not already exist, + it is created. + + [i]<>filename + opens file filename for reading + and writing, and assigns file + descriptor i to it. If + filename does not exist, it is + created. <link linkend="processsubref">process substitution</link> @@ -2429,11 +2450,11 @@ fi # If there are hidden files in /source/directory. - bunzip2 linux-2.6.13.tar.bz2 | tar xvf - -# --uncompress tar file-- | --then pass it to "tar"-- -# If "tar" has not been patched to handle "bunzip2", -# this needs to be done in two discrete steps, using a pipe. -# The purpose of the exercise is to unarchive "bzipped" kernel source. + bunzip2 -c linux-2.6.16.tar.bz2 | tar xvf - +# --uncompress tar file-- | --then pass it to "tar"-- +# If "tar" has not been patched to handle "bunzip2", +#+ this needs to be done in two discrete steps, using a pipe. +# The purpose of the exercise is to unarchive "bzipped" kernel source. Note that in this context the - is not @@ -6456,8 +6477,10 @@ echo "Last command argument processed = $last_cmd_arg" The $PPID of a process is the process ID (pid) of its parent process. - The PID of the currently running script is - $$, of course. + + The PID of the currently running script is + $$, of course. + Compare this with the + This operator is useful for generating filenames. + Converting graphic file formats, with filename change &cvt; + + Converting streaming audio files to + <emphasis>ogg</emphasis> + &ra2ogg; + + A simple emulation of getopt using substring extraction constructs. @@ -8629,6 +8660,7 @@ echo $? # 1 The argument list may contain wild cards. + If do is on same line as for, there needs to be a semicolon after list. @@ -8816,7 +8848,7 @@ echo $? # 1 - As is the case with for loops, + As is the case with for loops, placing the do on the same line as the condition test requires a semicolon. @@ -12222,7 +12254,7 @@ OneYearAgo=$(date --date='1 year ago') - sleep + sleep sleep @@ -13886,6 +13918,11 @@ function write_utf8_string { command is gunzip, which is the equivalent of gzip -d. + The option sends the output of + gzip to stdout. This + is useful when piping to other + commands. + The zcat filter decompresses a gzipped file to stdout, as possible input to a pipe or @@ -13895,6 +13932,7 @@ function write_utf8_string { utility). The zcat command is equivalent to gzip -dc. + On some commercial UNIX systems, zcat is a synonym for uncompress -c, and will not work on gzipped @@ -16325,6 +16363,22 @@ done linkend="fdiskref">fdisk. It may have unintended side-effects. + + The yes command parses variables. + For example: + + bash$ yes $BASH_VERSION +3.00.16(1)-release + 3.00.16(1)-release + 3.00.16(1)-release + 3.00.16(1)-release + 3.00.16(1)-release + . . . + + + This feature may not be particularly useful. + + @@ -17758,18 +17812,23 @@ setserial /dev/$DEVICE irq 0 ; setserial /dev/$DEVICE irq $IRQ< command - strace + trace - Diagnostic and debugging tool for tracing system - calls and signals. The simplest way of invoking it is - strace COMMAND. + System trace: + diagnostic and debugging tool for tracing system + calls and signals. This command and + ltrace, following, are useful for + diagnosing why a given program or package fails to + run . . . perhaps due to missing libraries or related + causes. bash$ strace df execve("/bin/df", ["df"], [/* 45 vars */]) = 0 uname({sys="Linux", node="bozo.localdomain", ...}) = 0 brk(0) = 0x804f5e4 + ... @@ -17780,6 +17839,37 @@ setserial /dev/$DEVICE irq 0 ; setserial /dev/$DEVICE irq $IRQ< + + ltrace + + ltrace + + + command + trace + + + Library trace: + diagnostic and debugging tool that traces library calls + invoked by a given command. + + + bash$ ltrace df +__libc_start_main(0x804a910, 1, 0xbfb589a4, 0x804fb70, 0x804fb68 <unfinished ...>: + setlocale(6, "") = "en_US.UTF-8" +bindtextdomain("coreutils", "/usr/share/locale") = "/usr/share/locale" +textdomain("coreutils") = "coreutils" +__cxa_atexit(0x804b650, 0, 0, 0x8052bf0, 0xbfb58908) = 0 +getenv("DF_BLOCK_SIZE") = NULL + + ... + + + + + + + nmap @@ -18370,7 +18460,7 @@ Average: all 6.33 1.70 14.71 0.00 77.26Job Control - ps + ps ps @@ -19364,6 +19454,7 @@ mount -o loop /dev/loop0 /mnt # Mount it. bMaxPacketSize0 8 idVendor 0x0000 idProduct 0x0000 + . . . @@ -19371,6 +19462,36 @@ mount -o loop /dev/loop0 /mnt # Mount it. + + lspci + + lspci + + + command + pci + + + Lists pci busses present. + + + bash$ lspci +00:00.0 Host bridge: Intel Corporation 82845 845 (Brookdale) Chipset Host Bridge (rev 04) + 00:01.0 PCI bridge: Intel Corporation 82845 845 (Brookdale) Chipset AGP Bridge (rev 04) + 00:1d.0 USB Controller: Intel Corporation 82801CA/CAM USB (Hub #1) (rev 02) + 00:1d.1 USB Controller: Intel Corporation 82801CA/CAM USB (Hub #2) (rev 02) + 00:1d.2 USB Controller: Intel Corporation 82801CA/CAM USB (Hub #3) (rev 02) + 00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev 42) + + . . . + + + + + + + + mkbootdisk @@ -20588,17 +20709,26 @@ let "z += 3" # Quotes permit the use of spaces in variable assignment. # -------------------------------------------------------------------- 1>filename - # Redirect stdout to file "filename". + # Redirect stdout to file "filename." 1>>filename - # Redirect and append stdout to file "filename". + # Redirect and append stdout to file "filename." 2>filename - # Redirect stderr to file "filename". + # Redirect stderr to file "filename." 2>>filename - # Redirect and append stderr to file "filename". + # Redirect and append stderr to file "filename." &>filename - # Redirect both stdout and stderr to file "filename". + # Redirect both stdout and stderr to file "filename." + + M>N + # "M" is a file descriptor, which defaults to 1, if not explicitly set. + # "N" is a filename. + # File descriptor "M" is redirect to file "N." + M>&N + # "M" is a file descriptor, which defaults to 1, if not set. + # "N" is another file descriptor. #============================================================================== + # Redirecting stdout, one line at a time. LOGFILE=script.log @@ -20773,6 +20903,22 @@ exec 3>&- # Now close it for the remainder of the s file. This sends all command output that would normally go to stdout to that file. + + + exec N > filename affects the entire + script or current shell. Redirection in + the PID of the script or shell + from that point on has changed. However . . . + + + N > filename affects only the newly-forked process, + not the entire script or shell. + + Thank you, Ahmed Darwish, for pointing this out. + + + + Redirecting <filename>stdout</filename> using <command>exec</command> @@ -21191,9 +21337,9 @@ echo "This line had better not echo." # Follows an 'exit' command. - A here string can be considered as - a stripped-down form of here document. It - consists of nothing more than COMMAND + A here string can be considered as + a stripped-down form of a here document. + It consists of nothing more than COMMAND <<<$WORD, where $WORD is expanded and fed to the stdin of COMMAND. @@ -21455,6 +21601,8 @@ exit 0 The dollar sign -- $ -- at the end of an RE matches the end of a line. + XXX$ matches XXX at the + end of a line. ^$ matches blank lines. @@ -22246,7 +22394,7 @@ fi A command block between curly braces does not launch a subshell. - { command1; command2; command3; ... } + { command1; command2; command3; . . . commandN; } @@ -24574,7 +24722,14 @@ trap 'echo "Control-C disabled."' 2 - Assigning reserved words or characters to variable names. + + + + + + Assigning reserved words or characters to variable names. + + case=value0 # Causes problems. 23skidoo=value1 # Also problems. # Variable names starting with a digit are reserved by the shell. @@ -24587,9 +24742,12 @@ echo $_ # $_ is a special variable set to last arg of last command. xyz((!*=value2 # Causes severe problems. # As of version 3 of Bash, periods are not allowed within variable names. + + Using a hyphen or other reserved characters in a variable name (or - function name). + function name). + var-1=23 # Use 'var_1' instead. @@ -24601,9 +24759,12 @@ function-whatever () # Error function.whatever () # Error # Use 'functionWhatever ()' instead. + + Using the same name for a variable and a function. This can make a - script difficult to understand. + script difficult to understand. + do_something () { echo "This function does something with \"$1\"." @@ -24615,13 +24776,17 @@ do_something do_something # All this is legal, but highly confusing. + + + Using whitespace inappropriately. In contrast to other programming languages, Bash can be quite - finicky about whitespace. + finicky about whitespace. + var1 = 23 # 'var1=23' is correct. # On line above, Bash attempts to execute command "var1" # with the arguments "=" and "23". @@ -24632,24 +24797,46 @@ if [ $a -le 5] # if [ $a -le 5 ] is correct. # if [ "$a" -le 5 ] is even better. # [[ $a -le 5 ]] also works. + + + + Not terminating with a semicolon the final + command in a code block within curly + brackets. + + { ls -l; df; echo "Done." } +# bash: syntax error: unexpected end of file + +{ ls -l; df; echo "Done."; } +# ^ ### Final command needs semicolon. + + + + + Assuming uninitialized variables (variables before a value is assigned to them) are zeroed out. An uninitialized variable has a value of null, - not zero. + not zero. + #!/bin/bash echo "uninitialized_var = $uninitialized_var" # uninitialized_var = + + + Mixing up = and -eq in a test. Remember, = is for comparing literal - variables and -eq for integers. + variables and -eq for integers. + if [ "$a" = 273 ] # Is $a an integer or string? if [ "$a" -eq 273 ] # If $a is an integer. @@ -24677,8 +24864,10 @@ then fi # Aborts with an error message. # test.sh: [: 273.0: integer expression expected + + Misusing string comparison operators. @@ -24686,41 +24875,55 @@ fi # Aborts with an error message. Numerical and string comparison are not equivalent &badop; + + Sometimes variables within test brackets ([ ]) need to be quoted (double quotes). Failure to do so may cause unexpected behavior. See , , and . + + + Commands issued from a script may fail to execute because the script owner lacks execute permission for them. If a user cannot invoke a command from the command line, then putting it into a script will likewise fail. Try changing the attributes of the command in question, perhaps even setting the suid bit (as root, of course). + + + Attempting to use - as a redirection operator (which it is not) will usually result in an unpleasant - surprise. + surprise. + command1 2> - | command2 # Trying to redirect error output of command1 into a pipe... # ...will not work. command1 2>& - | command2 # Also futile. Thanks, S.C. + + + + Using Bash version 2+ functionality may cause a bailout with error messages. Older Linux machines may have version 1.XX of Bash as the default - installation. + installation. + #!/bin/bash minimum_version=2 # Since Chet Ramey is constantly adding features to Bash, -# you may set $minimum_version to 2.XX, or whatever is appropriate. +# you may set $minimum_version to 2.XX, 3.XX, or whatever is appropriate. E_BAD_VERSION=80 if [ "$BASH_VERSION" \< "$minimum_version" ] @@ -24731,14 +24934,19 @@ then fi ... + + + Using Bash-specific functionality in a Bourne shell script (#!/bin/sh) on a non-Linux machine may cause unexpected behavior. A Linux system usually aliases sh to bash, but this does not necessarily hold true for a generic UNIX machine. + + Using undocumented features in Bash turns out to be a dangerous practice. In previous releases of this book there were several scripts that depended on the @@ -24748,13 +24956,18 @@ fi did not apply to negative integers. Unfortunately, in version 2.05b and later, that loophole disappeared. See . + + + + A script with DOS-type newlines (\r\n) will fail to execute, since #!/bin/bash\r\n - is not recognized, not the same as the - expected #!/bin/bash\n. The fix is to - convert the script to UNIX-style newlines. + is not recognized, not + the same as the expected #!/bin/bash\n. The + fix is to convert the script to UNIX-style newlines. + #!/bin/bash echo "Here" @@ -24771,24 +24984,34 @@ echo "There" exit 0 + + + + + A shell script headed by #!/bin/sh will not run in full Bash-compatibility mode. Some Bash-specific functions might be disabled. Scripts that need complete access to all the Bash-specific extensions should start with #!/bin/bash. + + Putting whitespace in front of the terminating limit string of a here document will cause unexpected behavior in a script. + + A script may not export variables back to its parent process, the shell, or to the environment. Just as we learned in biology, a child - process can inherit from a parent, but not vice versa. + process can inherit from a parent, but not vice versa. + WHATEVER=/home/bozo export WHATEVER exit 0 @@ -24797,9 +25020,16 @@ exit 0 bash$ - Sure enough, back at the command prompt, $WHATEVER remains unset. - + + + Sure enough, back at the command prompt, $WHATEVER remains unset. + + + + + + Setting and manipulating variables in a subshell, then attempting to use those same variables outside the scope of the subshell will @@ -24809,7 +25039,11 @@ exit 0 Subshell Pitfalls &subpit; + + + + Piping echo output to a tail -f /var/log/messages | grep "$ERROR_MSG" >> error.log # The "error.log" file will not have anything written to it. + - -- - + Using suid commands within scripts is risky, as it may compromise system security. Setting the suid permission on the script itself has no effect. + + Using shell scripts for CGI programming may be problematic. Shell script variables are not typesafe, and this can cause undesirable behavior as far as CGI is concerned. Moreover, it is difficult to cracker-proof shell scripts. + + + Bash does not handle the double slash (//) string correctly. + + + Bash scripts written for Linux or BSD systems may need fixups to run on a commercial UNIX (or Apple OSX) machine. Such scripts often employ GNU commands and filters which have greater functionality than their generic UNIX counterparts. This is particularly true of such text processing utilites as tr. + + + + A.J. Lamb and H.W. Petrie @@ -26563,6 +26809,51 @@ fi + + Bash, version 3.1 + + The version 3.1 update of Bash introduces a number of bugfixes + and a few minor changes. + + + + + The += operator is now permitted in + in places where previously only the = + assignment operator was recognized. + + a=1 +echo $a # 1 + +a+=5 # Won't work under versions of Bash earlier than 3.1. +echo $a # 15 + +a+=Hello +echo $a # 15Hello + + + Here, += functions as a string + concatenation operator. Note that its behavior + in this particular context is different than within a + let construct. + + a=1 +echo $a # 1 + +let a+=5 # Integer arithmetic, rather than string concatenation. +echo $a # 6 + +let a+=Hello # Doesn't "add" anything to a. +echo $a # 6 + + + + + + + + + @@ -26861,7 +27152,8 @@ fi Chris Morgan, Walter Dnes, Linc Fessenden, Michael Iatrou, Pharis Monalo, Jesse Gough, Fabian Kreutz, Mark Norman, Harald Koenig, Peter Knowles, Francisco Lobo, Mariusz Gniazdowski, Tedman Eng, - and David Lawyer (himself an author of four HOWTOs). + Achmed Darwish, Andreas Kühne, and David Lawyer (himself + an author of four HOWTOs). My gratitude to Chet Ramey and Brian Fox for writing Bash, @@ -28523,7 +28815,7 @@ fi Indirect variable reference - + Block of code @@ -30629,6 +30921,18 @@ done < `tail -f /var/log/messages` + + Checking whether a process is still running + + Given a process ID + (PID) as an argument, this script + will check, at user-specified intervals, whether + the given process is still running. You may use + the ps and sleep commands. + + + Primes @@ -31351,7 +31655,7 @@ fairly detailed rundown on the Playfair Cipher and its solution methods.Revision History - This document first appeared as a HOWTO in the late spring + This document first appeared as a 60-page HOWTO in the late spring of 2000. Since then, it has gone through quite a number of updates and revisions. This book could not have been written without the assistance of the Linux community, and especially @@ -31527,22 +31831,27 @@ fairly detailed rundown on the Playfair Cipher and its solution methods. 05 Jun 2005 - BOXBERRY release: Bugfixes, some materials added. + BOXBERRY release: Bugfixes, some material added. 28 Aug 2005 - POKEBERRY release: Bugfixes, some materials added. + POKEBERRY release: Bugfixes, some material added. 23 Oct 2005 - WHORTLEBERRY release: Bugfixes, some materials added. + WHORTLEBERRY release: Bugfixes, some material added. 26 Feb 2006 - BLAEBERRY release: Bugfixes, some materials added. + BLAEBERRY release: Bugfixes, some material added. + + + + 15 May 2006 + SPICEBERRY release: Bugfixes, some material added. @@ -31555,7 +31864,7 @@ fairly detailed rundown on the Playfair Cipher and its solution methods.Mirror Sites + url="http://thegrendel.150m.com/abs-guide-3.9.tar.bz2"> The latest update of this document, as an archived tarball including both the SGML source and rendered HTML, may diff --git a/LDP/guide/docbook/abs-guide/bubble.sh b/LDP/guide/docbook/abs-guide/bubble.sh index 045be447..4aaa5ebc 100644 --- a/LDP/guide/docbook/abs-guide/bubble.sh +++ b/LDP/guide/docbook/abs-guide/bubble.sh @@ -65,7 +65,7 @@ do then exchange $index `expr $index + 1` # Swap. fi - let "index += 1" + let "index += 1" # Or, index+=1 on Bash, ver. 3.1 or newer. done # End of inner loop # ---------------------------------------------------------------------- diff --git a/LDP/guide/docbook/abs-guide/ex67.sh b/LDP/guide/docbook/abs-guide/ex67.sh index 21b7c1c1..c208b1c8 100644 --- a/LDP/guide/docbook/abs-guide/ex67.sh +++ b/LDP/guide/docbook/abs-guide/ex67.sh @@ -28,6 +28,9 @@ while [ "$index" -lt "$element_count" ] do # List all the elements in the array. echo ${colors[$index]} let "index = $index + 1" + # Or: + # index+=1 + # if running Bash, version 3.1 or later. done # Each array element listed on a separate line. # If this is not desired, use echo -n "${colors[$index]} " diff --git a/LDP/guide/docbook/abs-guide/gcd.sh b/LDP/guide/docbook/abs-guide/gcd.sh index 31556fa8..a7183579 100644 --- a/LDP/guide/docbook/abs-guide/gcd.sh +++ b/LDP/guide/docbook/abs-guide/gcd.sh @@ -13,7 +13,7 @@ #+ The gcd = dividend, on the final pass. # # For an excellent discussion of Euclid's algorithm, see -# Jim Loy's site, http://www.jimloy.com/number/euclids.htm. +#+ Jim Loy's site, http://www.jimloy.com/number/euclids.htm. # ------------------------------------------------------ @@ -33,7 +33,7 @@ gcd () { dividend=$1 # Arbitrary assignment. - divisor=$2 #+ It doesn't matter which of the two is larger. + divisor=$2 #! It doesn't matter which of the two is larger. # Why not? remainder=1 # If uninitialized variable used in loop, diff --git a/LDP/guide/docbook/abs-guide/life.sh b/LDP/guide/docbook/abs-guide/life.sh index 0fb67a93..2e11409e 100644 --- a/LDP/guide/docbook/abs-guide/life.sh +++ b/LDP/guide/docbook/abs-guide/life.sh @@ -31,12 +31,23 @@ startfile=gen0 # Read the starting generation from the file "gen0". # if [ -n "$1" ] # Specify another "generation 0" file. then - if [ -e "$1" ] # Check for existence. - then startfile="$1" - fi fi +############################################ +# Abort script if "startfile" not specified +#+ AND +#+ "gen0" not present. + +E_NOSTARTFILE=68 + +if [ ! -e "$startfile" ] +then + echo "Startfile \""$startfile"\" missing!" + exit $E_NOSTARTFILE +fi +############################################ + ALIVE1=. DEAD1=_ @@ -337,9 +348,9 @@ done echo -exit 0 +exit 0 # END + -# -------------------------------------------------------------- # The grid in this script has a "boundary problem." # The the top, bottom, and sides border on a void of dead cells. diff --git a/LDP/guide/docbook/abs-guide/q-function.sh b/LDP/guide/docbook/abs-guide/q-function.sh index 66b47069..06c71f56 100644 --- a/LDP/guide/docbook/abs-guide/q-function.sh +++ b/LDP/guide/docbook/abs-guide/q-function.sh @@ -9,7 +9,7 @@ # The first 20 terms of the series are: # 1 1 2 3 3 4 5 5 6 6 6 8 8 8 10 9 10 11 11 12 -# See Hofstadter's book, "Goedel, Escher, Bach: An Eternal Golden Braid", +# See Hofstadter's book, _Goedel, Escher, Bach: An Eternal Golden Braid_, #+ p. 137, ff. diff --git a/LDP/howto/docbook/HOWTO-INDEX/howtoChap.sgml b/LDP/howto/docbook/HOWTO-INDEX/howtoChap.sgml index 8bc1bccd..50594691 100644 --- a/LDP/howto/docbook/HOWTO-INDEX/howtoChap.sgml +++ b/LDP/howto/docbook/HOWTO-INDEX/howtoChap.sgml @@ -2181,7 +2181,7 @@ This HOWTO has been removed for review. Linksys-Blue-Box-Router-HOWTO, Linksys Blue Box Router HOWTO -Updated: Dec 2005. +Updated: May 2006. Hints and tips for managing Linksys routers from a Linux system, including the firmware upgrade procedure. diff --git a/LDP/howto/docbook/HOWTO-INDEX/hwSect.sgml b/LDP/howto/docbook/HOWTO-INDEX/hwSect.sgml index 567786e4..896ed523 100644 --- a/LDP/howto/docbook/HOWTO-INDEX/hwSect.sgml +++ b/LDP/howto/docbook/HOWTO-INDEX/hwSect.sgml @@ -1078,7 +1078,7 @@ scanner device on a system running Linux. Linksys-Blue-Box-Router-HOWTO, Linksys Blue Box Router HOWTO -Updated: Dec 2005. +Updated: May 2006. Hints and tips for managing Linksys routers from a Linux system, including the firmware upgrade procedure. diff --git a/LDP/howto/docbook/HOWTO-INDEX/networkingSect.sgml b/LDP/howto/docbook/HOWTO-INDEX/networkingSect.sgml index 61dd52bd..d673534e 100644 --- a/LDP/howto/docbook/HOWTO-INDEX/networkingSect.sgml +++ b/LDP/howto/docbook/HOWTO-INDEX/networkingSect.sgml @@ -937,7 +937,7 @@ How to enable the Linux IP Masquerade feature on a given Linux host. Linksys-Blue-Box-Router-HOWTO, Linksys Blue Box Router HOWTO -Updated: Dec 2005. +Updated: May 2006. Hints and tips for managing Linksys routers from a Linux system, including the firmware upgrade procedure. diff --git a/LDP/howto/docbook/Linksys-Blue-Box-Router-HOWTO.xml b/LDP/howto/docbook/Linksys-Blue-Box-Router-HOWTO.xml index fbdfd59c..9e44d19a 100644 --- a/LDP/howto/docbook/Linksys-Blue-Box-Router-HOWTO.xml +++ b/LDP/howto/docbook/Linksys-Blue-Box-Router-HOWTO.xml @@ -1,6 +1,6 @@ - @@ -20,6 +20,15 @@ + + 2.3 + 2006-05-19 + esr + + Revised the list of open firmware distributions, and other minor + corrections. + + 2.2 2005-12-01 @@ -149,7 +158,7 @@ machine over a cable. Also note that if you go looking for one of these now, be sure to get the WRT54GL — note the L suffix. At Version 5 and up, the vanilla -WRT54G is different hardware with less RAM that runs a propriatary +WRT54G is different hardware with less RAM that runs a proprietary VxWorks OS. @@ -184,9 +193,7 @@ ignore you. to be used as gateway boxes on a home Ethernet. Typically, you'll hook one up to a DSL or cable modem, which will automatically switch into bridge mode and simply pass packets between your ISP's router and the Linksys box. -Here's a recognition -chart of these products. + If you want to use a general-purpose PC running Linux as a firewall, have fun — but these little boxes are more efficient. The nicest @@ -202,9 +209,9 @@ year, and I heard grumbling from others about similar problems. Unfortunately when I tried other low-end brands (Belkin, Buffalo) they proved to have gross design errors. The Belkin had brain-damage in its firewall rules that interfered with local SMTP, and the Buffalo -intermittently refused connections for no apparent reason. So I'm back -with Linksys. hoping my WRT54G doesn't turn into a doorstop within a couple -of months. +intermittently refused connections for no apparent reason. So I went back +with Linksys, hoping my WRT54G wouldn't turn into a doorstop within a couple +of months. As of mid-2006, I've been OK for about 24 months. (Building one of these puppies is not rocket science. I can only conjecture that the competitive pressure is driving the manufacturers to cut @@ -218,8 +225,8 @@ what marketers call a flank guard, a low-end brand designed to protect the margins and brand image of Cisco's commercial-grade networking products. This means that Linksys boxes are no longer acquiring new firmware features, and some old ones like stateful packet inspection almost -certainly won't be coming back. Provided you can live wthin these limits, -this is actually good; simpler firmware is stable firmware. +certainly won't be coming back. Provided you can live within these limits, +this is actually good; simpler firmware is more stable firmware. At minimum, a live Linksys box will do the following things for you: @@ -260,7 +267,7 @@ built into the firmware, a good thing if your net connection is down. Unfortunately, you're in trouble if you have to bring in Linksys tech -support. On the one occasion that I called them, the first tech +support. On the one occasion that I called them (in 2003), the first tech I raised couldn't even speak English, and the second was barely competent at it. Both were complete and utter idiots whose response to any nontrivial question was to put me on infinite hold while they went @@ -285,8 +292,7 @@ reported that turning off the remote admin feature doesn't work side. This bug is still present in the 2.02 firmware, October 2004. It means that if you leave your password at default, any script kiddie can break in, steal your WEP, and scramble your configuration. The Linksys -people get the moron medal with oak-leaf cluster for this -screwup. +people get the moron medal with oak-leaf cluster for this screwup. (I don't know if this bug is still present in the 3.x firmware. It would be a good idea to check.) @@ -321,7 +327,7 @@ network. There are two more steps for older firmware versions only. You can -ignore these if you have 2.x firmware. +ignore these if you have 2.x or later firmware. Disable AOL Parental Controls. @@ -365,9 +371,9 @@ WINE. Not recommended. The third way is to use tftp. This is how I did it the first time, before Linksys added the Upgrade firmware to the firmware, and I document it here for completeness -even though I now recommend that method. There is a tftp client included -with Red Hat Linux. To upgrade your firmware this way, do the following -steps: +even though I now recommend their upgrade method. There is a tftp client +included with Red Hat Linux. To upgrade your firmware this way, do the +following steps: @@ -378,9 +384,7 @@ your basic settings but clear some advanced ones. Download a copy of the new firmware. -You should find it at Firmware -Upgrades for your Linksys Products on the Linksys site. Note that +Follow the Downloads link from the Linkys main page. Note that what you get may well be marked For Windows Users and be a zip archive. Open it in a scratch directory, because it will rudely create several Windows files wherever you unpack it. The file you need will be @@ -395,9 +399,9 @@ until both the Password and Confirm fields are blank, and click Apply. -Cross your fingers and load the firmware. -The command session you want will to see will look something like -this, with your router's IP address substituted for +Cross your fingers and load the +firmware. The command session you want will to see will look +something like this, with your router's IP address substituted for 192.168.1.1: @@ -425,11 +429,7 @@ the firmware version number will have changed. Hacking the hardware -There is a page that tells you how to -casemod the Linksys WAP11 wireless access point. - -Linksys boxes have firmware support for a serial console, The circuit +Linksys boxes have firmware support for a serial console. The circuit board has traces for two serial ports, but you have to do some fairly serious modding to get them working. This page will @@ -438,12 +438,12 @@ show you how. Hacking the software -Linxsys routers run Linux from firmware. Linksys supplies source code on its -site. +Linksys routers run Linux from firmware. Linksys supplies source +code on its site; look for "GPL Code Center" under technical +support. There are several replacements for the WRT54G firmware. All -add certain commn features such as (a) the capability to ssh into the +add certain common features such as (a) the capability to ssh into the Linux running on the box, (b) European WiFi channels, and (c) VPN service. @@ -459,6 +459,14 @@ Supports SNMP/mrtg. Said to have a good interface, convenient for home use. Intended for Wireless ISPs, lots of stuff for routing and repeater operation. Open source, but you can buy support and private-release subscriptions. +This outfit has been slammed for GPL noncompliance and apparently lost +a lot of the good reputation it used to have. + + + +DD-WRT + +A fork of the SveaSoft codebase from a few years back. @@ -501,8 +509,8 @@ Wrt54g by Seattle wireless.net. Utilities -There is a Unix utility called linksysmon that -talks with these boxes via SNMP. There is a There is a Unix utility called linksysmon +that talks with these boxes via SNMP. Look at the Linksysmon project site. Linksysmon is a tool for monitoring Linksys BEFSR41 and BEFSR11