##################################################################### # SCRIPT: SS_IgnoreURL # # This script checks if a URL falls within a list of domains to be ignored. # The URL to checkk is assigned using FVA (Forward Variable Assignment) # for str variable $URL. The value of $URL is of form # "http://www.xxx.yyy" or "http://xxx.yyy.zzz/www.../qqq.html" . # # The list of domains to be ignored is passed using FVA for str variabls # $ignore_domains. The format is || ... # Each is in the form "http://www.abc.def" . # # The http:// part is necessary in both domains as well as URLs. # # If the URL passes the check (it is not in the ignored domains list), # the script outputs the original URL. If it does not pass the check # (if it IS in the list of ignored domains), it output nothing. # # This script can be stored, and edited as needed, in a file called # SS_IgnoreURL.txt. The script can then be called as # # script SS_IgnoreURL.txt URL("") ignore_domains("||...") # ##################################################################### var str URL # Name of the URL to check var str ignore_domains # List of domains to be ignored. Domains are separated by |. # We will change the value of $wsep to suit our purpose. # But, we will save the original value, so we can restore it # after we are done. var str saved_wsep set $saved_wsep = $wsep set $wsep="|" var bool found set $found = false # We will set it to true when we find a match. while ( ( NOT ($found) ) AND ( $ignore_domains <> "" ) ) do # Get the next domain. var str domain wex -e "1" $ignore_domains > $domain # Note we used -e in the wex command to allow for the possibility that our # caller may have erroneously a few extra | in $ignore_domains, for example, # "||||". In that case, without the -e option, we will go # in an infinite loop. So, we added the -e option in the wex command, and, # going forward, we will check if $domain is empty. if ( $domain <> "" ) do # Is $domain part of our $URL ? # We will create a dynamic argument for the sen command in the form ^domain^ var str sen_arg set $sen_arg = "^"+$domain+"^" if ( { sen -c $sen_arg $URL } > 0 ) # We found a match. set $found = true endif done endif done # Did we find a match ? Echo the URL only if we did not find a match. if ( NOT ($found) ) # No match. Output the URL echo $URL endif # Restore original value of $wsep. set $wsep = $saved_wsep