test area

This is the of the index-press plugin with settings of 8 characters at least per word.  It automatically searches for words on the site and provides a list that an Administrator can further cull.   It does not however adapt easily to phrases such as “Changing your password as the phrase  is broken up and the “Changing” word may have been deleted by the administrator as too general.  What we need is to be able click on a line (for example :Changing your password”) and for that text to automatically be searched for within the site.  Is there a widget available?? nb

 

[innndex-press]

indexpress temporarily disabled.

 

The following is the result of a copy and paste (right click copy ) from TIP mediawiki. Some problems with formatting may have been resolved by installing and activating the WPCode Highlight  plugin (nb) and any code should be between pre tags.  Nice automatic syntax highlighting!! (nb)

Self documenting bash script options

This Linux HOWTO describes a process to display a help window for a bash script that has several command line options.

Most bash scripts can be called with a varying number of options (using the getopts syntax) and it is sometimes hard keeping up with what each option does, particularly if there are many.

Inside the script these options are managed in the getops list, so a print-out of the current option list is useful. However, the options may change in time and short of updating a help message file each time, or opening the script and viewing the relevant area, it is useful to provide a synchronised way of displaying the options in a readable format.

A typical getopts sequence might look like the following:

Image:Nab-sd1.png
In this case the area of interest is the getops sequence and to demarcate this place ###START (3 ‘#’) at the start and ####END at the end of the sequence (as these are comments they can be inserted anywhere).

The following function within the script then gathers all lines between ###START and ####END, tidies the content up a bit (this is optional) and shows the result in a zenity window.

 

 

print_ops() {
    #place a start marker consisting of three # and an end marker of four # around getopts 
    #create a tmp file here

    echo > /tmp/tmp.txt  # start with a blank line
    t=` sed -n  '/[#]\{3\}/,/[#]\{4\}/p ' "$0" >> /tmp/tmp.txt ` #get range between 3#s and 4#s

    #tidy up tmp file  (note these are mostly specific but will work in general elsewhere (but check/change as needed)
    t=`  cat /tmp/tmp.txt | sed -e 	's/^[ \t]*//   ; s/"//g  ; s/)/\t:\t/ ; \
 		    	     	         s/s=$s/    /  ; s/;;//g      ; s/=/\t=  / ; \
		    		         s/^[#]\{4\}// ; s/[#]\{3\}// ; s/^/\t/ ; s/-/ / ; s/+/ /; s/#/\t\t\t\t\t: / ' `
    # sed expr in order : del leading white space; replace all "; repl ) with a tab : tab; repl s=$s with 4 spaces;
    # del all ;; ; repl = with tab = sp ; del the start and end marker #s; add a tab to the start of each line; 
    # repl first - with sp; put 5 tabs in front of #  (comments)

    #rewrite /tmp/tmp.txt
    `echo "$t"  > /tmp/tmp.txt`

    #show in a zenity window
    zenity --text-info --title="Options for $0" --filename="/tmp/tmp.txt" --height=1000 --width=1200
}

 

While the output can be further tidied up and formatted, this will show the raw getops list in a zenity window as shown below.

To try this add the ### and #### tags around the getops list in your script (yourscript.sh), include the function (or its contents) and pass the ‘h’ option when calling it:

 

 

yourscript.sh -h

Image:Nab-sd2.png

Note: There is a related bash syntax involving what are known as Here Documents or Strings that provide a way of embedding message blocks in files (eg see: http://wiki.bash-hackers.org/syntax/redirection )