[CALUG] library script

James Ewing Cottrell 3rd JECottrell3 at Comcast.NET
Fri Jul 9 11:05:15 EDT 2010


Cool. It's nice that you can even DO that. However, the script is 
UNREADABLE, and most importantly, the differences are buried .

Try breaking the URL up into pieces, as follows:

host=http://polaris.hclibrary.org
path=polaris/search/searchresults.aspx
arg1="ctx=1.1033.0.0.6&type=Advanced&term=$SEARCH_TERM&term2=&term3=&term4="
arg2="by2=KW&by3=KW&by4=KW&bool1=And&bool2=And&bool3=And
arg4="limit=TOM=*&sort=RELEVANCE&page=0"

case $OPTION in
(-a)    arg3="by=AU";;
(-i)    arg3="by=ISBN";;
(-t)    arg3="by=TI";;
(*)    usage;;
esac

exec firefox --new-tab "$host/$path?$arg1&$arg2&$arg3&$arg4"

Now, if you wanted to add a -d (for date: by=DA) option, well, it's so 
simple, Even a Caveman Could Do It.

Please not that any source code, in any language should not exceed 80 
characters in width if possible.

JIM

On 7/6/2010 3:30 PM, John L. Cunningham wrote:
> The redesigned Howard County Public Library site is too pointy-clicky
> for my taste.  Therefore, I have written a rudementary bash script that
> allows me to search the catalog from the command line.
>
>
> --- BEGIN hcllookup.sh ---
> #!/bin/bash
>
> OPTION="$1"
> shift
> SEARCH_TERM="$*"
>
> case "$OPTION" in
> 	-a)
> 	firefox --new-tab "http://polaris.hclibrary.org/polaris/search/searchresults.aspx?ctx=1.1033.0.0.6&type=Advanced&term=$SEARCH_TERM&term2=&term3=&term4=&by=AU&by2=KW&by3=KW&by4=KW&bool1=And&bool2=And&bool3=And&limit=TOM=*&sort=RELEVANCE&page=0"
> 	;;
> 	-i)
> 	firefox --new-tab "http://polaris.hclibrary.org/polaris/search/searchresults.aspx?ctx=1.1033.0.0.6&type=Advanced&term=$SEARCH_TERM&term2=&term3=&term4=&by=ISBN&by2=KW&by3=KW&by4=KW&bool1=And&bool2=And&bool3=And&limit=TOM=*&sort=RELEVANCE&page=0"
> 	;;
> 	-t)
> 	firefox --new-tab "http://polaris.hclibrary.org/polaris/search/searchresults.aspx?ctx=1.1033.0.0.6&type=Advanced&term=$SEARCH_TERM&term2=&term3=&term4=&by=TI&by2=KW&by3=KW&by4=KW&bool1=And&bool2=And&bool3=And&limit=TOM=*&sort=RELEVANCE&page=0"
> 	;;
> 	*)
> 	printf "Usage: hcllookup [OPTION] [SEARCH TERM(S)...]\n\t-a, Author\n\t-i, ISBN\n\t-t, Title\n"
> 	;;
> esac
> --- END hcllookup.sh ---
>
>
> John
>
> _______________________________________________
> CALUG mailing list
> CALUG at unknownlamer.org
> http://lists.unknownlamer.org/listinfo/calug
>
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.830 / Virus Database: 271.1.1/2985 - Release Date: 07/06/10 02:36:00
>
>    

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.unknownlamer.org/pipermail/calug/attachments/20100709/eb892c18/attachment.htm 


More information about the CALUG mailing list