PRODUCT






Home









Free Download








Installation Instructions





FAQ





FAQ








Ask A Question





LEARN SCRIPTING





Overview








Lesson 1








2


3


4


5








Exam





SAMPLE SCRIPTS





Computer








Internet








Administrators








Developers








Data








Miscellaneous





HELP / DOCUMENTATION





Commands








Automated Internet








Automated Editors








Sample Scripts








Precompiled Functions








System Features






  Help Page - SS_FindEmailStrs

( Some help pages may not display correctly in html because those help pages may have sample code
in them, part of which may be mis-interpreted as html tags.

All help pages, including this help page, are available in biterScripting with the help command. )




Sample Script SS_FindEmailStrs Purpose Searches locally stored emails for one or more search strings. Source Code ##################################################################### # SCRIPT: SS_FindEmailStrs.txt # # This script searches email files on a local computer based on # search strings. The script lists the email file name and the # contents of the email file, for each email file that contains # ALL of the search strings. # # Multiple search strings can be specified. The script lists email files # that contain ALL OF the search strings. Search strings are separated # by a separator character. The separator character is specified # using the input argument sep. The default separator character is # the plus sign (+). # # The script accepts following input arguments. # # storagedir - directory where email files are stored. If not assigned, # current directory will be used. # # files - a file pattern for email files. If not assigned, # "*" will be used, which means all files will be treated as email files. # # search_strings - the search strings separated by a separator character. # Email files will be searched for each of these strings. If not assigned, # an empty search string will be used, which will result in errors. # # sep - the separator character. If not assigned, the plus sign (+) will be used. # # lines - an integer number. Only the first $lines will be searched. For example, if # this argument is assigned the value 100, only the first 100 lines of each email file # will be searched. Often times, email attachments are contained in an encoded format # within the email file. This makes the file size too large, and the execution of this # scrip slow. To speed it up, this argument can be use to search only in, say, first 100 lines. # # Call this script as following. # # To search for a single string "joe" (search string does not contain the plus sign), use the following. # script "SS_FindEmailStrs.txt" storagedir("C:/Email") files("*.eml") search_strings("joe") lines(100) # # To search for a single string "joe+ana" (the search string itself contains the plus sign), use the following. # script "SS_FindEmailStrs.txt" storagedir("C:/Email") files("*.eml") search_strings("joe+ana") sep(";") lines(100) # # To search for two strings "joe" and "ana" (neither search string contains the plus sign), use the following. # script "SS_FindEmailStrs.txt" storagedir("C:/Email") files("*.eml") search_strings("joe+ana") lines(100) # # To search for two strings "joe+genovicci" and "ana+wilkes" (search strings contain the plus sign), use the following. # script "SS_FindEmailStrs.txt" storagedir("C:/Email") files("*.eml") search_strings("joe+genovicci;ana+wilkes") sep(";") lines(100) # ##################################################################### # Input arguments. var string storagedir, files, search_strings, sep var integer lines # Is $storagedir assigned ? If not, assign current directory. if ($storagedir == "") scd > $storagedir endif # Is $files assigned ? If not, assign "*". if ($files == "") set $files = "*" endif # We don't need to check if $search_strings is assigned. If not assigned, the script will return # errors. # Is $sep assigned ? If not, assign the plus sign. if ($sep == "") set $sep = "+" endif # Is $lines assigned ? If so, create an argument string for the lex command to strip # off lines after the first $lines lines in the content of each email file. var str lex_argument if ($lines > 0) set $lex_argument = makestr(int($lines))+"[" endif # Save the current value of word separator ($wsep). Set $wsep to $sep. var str saved_wsep ; set $saved_wsep = $wsep set $wsep = $sep # Collect a list of email files. var string list ; lf -rng $files $storagedir > $list while ($list <> "") do # Get the next email file. var string filedir ; lex "1" $list > $filedir echo -e "Processing email file: " $filedir # Get the contents of the email file. var string content ; repro $filedir > $content # Is $lex_argument assigned ? If so, strip off the lines after the first $lines lines. if ($lex_argument <> "") lex -e $lex_argument $content > null endif # How many search strings are there ? var integer count ; set $count = { wen -e $search_strings } # Loop through $search_strings one by one. Check if each search string # is present in $content. var bool is_present ; set $is_present = true var integer index ; set $index = 1 while ( ($is_present) AND ($index <= $count) ) do # Get the next search string. var str search_string ; set $search_string = { wex -p (makestr(int($index))) $search_strings } # If $search_string is not present in $content, set $is_present to false. if ( { sen -c ("^"+$search_string+"^") $content } <= 0 ) set $is_present = false endif set $index = $index + 1 done # Print the file name and contents if all search strings present in this email file. if ($is_present) do echo "\n\n =========== EMAIL FILE " $filedir " =========== " repro $filedir done endif done # Restore the previous value of $wsep. set $wsep = $saved_wsep

2008-2013, biterScripting.com. All rights reserved.
biterScripting, biterScript, biterBrowser, biterMobile, biterScripting.com, FVA (Forward Variable Assignment) are trademarks of biterScripting.com. Is it biterScripting-compatible ? is a service mark of biterScripting.com. Explorer, Unix, Windows are trademarks, service marks or other forms of intellectual property of their respective owners.