d2b194d34a3a903d41bd61d6a83365fca8f89257
kuhn
  Mon Oct 28 11:16:28 2013 -0700
working with Matt.  added quotes around a variable because echo croaks if a link has and ampersand.  renamed a variable to make it more intuitive when reading. added ftp to http in a grep because ftp is not an error code. refs #11809
diff --git src/utils/qa/checkTrackUiLinks.csh src/utils/qa/checkTrackUiLinks.csh
index e7f378e..1dd6a48 100755
--- src/utils/qa/checkTrackUiLinks.csh
+++ src/utils/qa/checkTrackUiLinks.csh
@@ -11,31 +11,31 @@
 ################################
 
 onintr cleanup
 
 set tableinput=""
 set tables=""
 set machine="hgwbeta"
 set host=""
 set rr="false"
 set baseUrl=""
 set target=""
 set cgi=""
 set hgsid=""
 set db=""
 set pgsWErrors=0
-set totalPgs=0
+set pgsChkd=0
 
 if ( $#argv < 2 || $#argv > 3 ) then
   echo
   echo "  checks all links on trackUi pages for a track."
   echo
   echo "    usage:  database tablelist [machine]"
   echo '           tablelist may also be single table or "all"'
   echo "           machine defaults to hgwbeta"
   echo
   echo '    note: includes assembly description.html page if "all"'
   echo
   exit
 else
   set db=$argv[1]
   set tableinput=$argv[2]
@@ -76,74 +76,73 @@
   set tables=$tableinput
 endif
 
 # set hgsid so don't fill up sessionDb table
 set baseUrl="http://$machine.cse.ucsc.edu"
 set hgsid=`htmlCheck  getVars $baseUrl/cgi-bin/hgGateway | grep hgsid \
   | head -1 | awk '{print $4}'`
 
 echo "hgw1 hgw2 hgw3 hgw4 hgw5 hgw6" | grep $machine
 if ( $status ) then
   set rr="true"
 endif
 
 # process descriptions page for "all" choice
 if ( "all" == $tableinput ) then
-  if ( "hgwdev" == $machine ) then
-    set tables=`hgsql -Ne "SELECT tableName FROM trackDb WHERE html != ''" $db`
-  else
-    set tables=`hgsql -h $sqlbeta -Ne "SELECT tableName FROM trackDb WHERE html != ''" $db`
+  if ( "hgwdev" != "$machine" ) then
     set host="-h $sqlbeta"
   endif
+  set tables=`hgsql $host -Ne "SELECT tableName FROM trackDb WHERE html != ''" $db`
   set tables="description.html $tables"
 endif
 
 # check links on all table.html pages
 foreach table ( $tables )
   rm -f errorsOnPg$$
   if ( $table == "description.html" ) then
     set cgi="hgGateway?hgsid=$hgsid&db=$db"
   else
     set cgi="hgTrackUi?hgsid=$hgsid&db=$db&g=$table"
   endif
   set target="$baseUrl/cgi-bin/$cgi"
   htmlCheck getLinks "$target" | egrep "ftp:|http:" | grep -v ucsc > $db.$table.outsideLinks$$
+
   if ( ! -z  $db.$table.outsideLinks$$ ) then
     foreach link ( `cat $db.$table.outsideLinks$$` )
-      echo $link >>& errorsOnPg$$
+      echo "$link" >>& errorsOnPg$$
       htmlCheck ok "$link" >>& errorsOnPg$$
     end
-    grep -B1 -v http errorsOnPg$$ > /dev/null
+    egrep -B1 -v "ftp:|http:" errorsOnPg$$ > /dev/null
     if ( ! $status ) then
       echo $table
       echo "=============="
       grep -B1 -v http errorsOnPg$$
       echo
       @ pgsWErrors= $pgsWErrors + 1
     endif
   endif
-  @ totalPgs = $totalPgs + 1
+  @ pgsChkd= $pgsChkd + 1
   rm -f errorsOnPg$$
   rm -f $db.$table.outsideLinks$$
 end
 
 echo "Summary"
 echo "======= ======="
-if ( $totalPgs == 1 ) then
-  echo $totalPgs "page checked"
+if ( $pgsChkd == 1 ) then
+  echo $pgsChkd "page checked"
 else
-  echo $totalPgs "pages checked"
+  echo $pgsChkd "pages checked"
 endif
 if ( $pgsWErrors > 0 ) then
   if ( $pgsWErrors == 1 ) then
     echo $pgsWErrors "page with error(s) found"
   else
     echo $pgsWErrors "pages with errors found"
   endif
 else
   echo "No errors found!"
 endif
 echo
 
 cleanup:
 rm -f error$$
 rm -f $db.$table.outsideLinks$$