Sunday, September 13, 2026

BASH ScripT for FOIA et. al. Data-mining

 #!/bin/bash


# Chemical Dumping Information Search Automation

# Purpose: Locate publicly available records about chemical dumping at Bumpus Cove Rd, Erwin TN 37640 (1970s)


# Configuration

SEARCH_DIR="./erwin_tn_chemical_search_results"

TIMESTAMP=$(date +%Y%m%d_%H%M%S)

LOG_FILE="$SEARCH_DIR/search_log_$TIMESTAMP.txt"


# Create results directory

mkdir -p "$SEARCH_DIR"


# Function to log output

log_message() {

    echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"

}


# Function to perform web searches using curl

search_online() {

    local query="$1"

    local source_name="$2"

    

    log_message "Searching $source_name for: $query"

    

    # Note: These are examples. Actual implementations depend on API availability

    # You may need API keys or alternative approaches for some sources

    

    case "$source_name" in

        "google")

            # Using a simple approach - encode query and open in browser

            query_encoded=$(echo "$query" | sed 's/ /+/g')

            echo "https://www.google.com/search?q=$query_encoded" >> "$SEARCH_DIR/google_queries_$TIMESTAMP.txt"

            ;;

        "archive")

            # Internet Archive Wayback Machine

            query_encoded=$(echo "$query" | sed 's/ /%20/g')

            echo "https://web.archive.org/web/*/erwin,+tennessee+chemical+dump" >> "$SEARCH_DIR/archive_queries_$TIMESTAMP.txt"

            ;;

        "epa")

            # EPA Superfund and environmental records

            echo "https://www.epa.gov/superfund" >> "$SEARCH_DIR/epa_queries_$TIMESTAMP.txt"

            ;;

    esac

}


# Function to search local resources

search_local_records() {

    log_message "Searching for local records and files..."

    

    # Search for any local PDFs, documents mentioning the location

    if command -v find &> /dev/null; then

        find . -type f \( -name "*.pdf" -o -name "*.txt" -o -name "*.doc" \) \

            -exec grep -l "Bumpus Cove\|Erwin\|chemical.*dump\|1970s" {} \; \

            2>/dev/null >> "$SEARCH_DIR/local_files_$TIMESTAMP.txt"

        log_message "Local file search completed"

    fi

}


# Function to generate research guide

generate_research_guide() {

    local guide_file="$SEARCH_DIR/research_guide_$TIMESTAMP.txt"

    

    cat > "$guide_file" << 'EOF'

RESEARCH GUIDE: Bumpus Cove Rd Chemical Dumping (Erwin, TN 37640 - 1970s)


PUBLIC SOURCES TO CONSULT:


1. EPA RESOURCES:

   - EPA Superfund Sites Database (epa.gov/superfund)

   - CERCLIS database (Comprehensive Environmental Response, Compensation, and Liability Information System)

   - State environmental agency records


2. INTERNET ARCHIVE:

   - Wayback Machine (web.archive.org)

   - Historical newspaper archives accessible through it


3. GOVERNMENT RECORDS:

   - Campbell County, TN Courthouse (County Clerk records)

   - Tennessee Department of Environment and Conservation (TDEC)

   - FOIA requests to EPA Region 4 (covers Tennessee)


4. NEWSPAPER ARCHIVES:

   - Newspapers.com

   - ProQuest Historical Newspapers

   - Local Erwin/Campbell County historical societies

   - Knoxville News Sentinel archives (regional coverage)


5. LIBRARY RESOURCES:

   - Tennessee State Library and Archives

   - Library of Congress (loc.gov)

   - University of Tennessee Special Collections


6. PUBLIC DATABASES:

   - State Superfund sites lists

   - USGS records

   - Historical industrial records


SEARCH TERMS TO USE:

- "Bumpus Cove" chemical dump

- Erwin Tennessee 1970s chemical

- Campbell County environmental contamination

- Tennessee chemical waste 1970s

EOF

    

    log_message "Research guide generated: $guide_file"

}


# Function to create FOIA request template

create_foia_template() {

    local foia_file="$SEARCH_DIR/foia_request_template_$TIMESTAMP.txt"

    

    cat > "$foia_file" << 'EOF'

FREEDOM OF INFORMATION ACT (FOIA) REQUEST TEMPLATE


To: [Agency Name]

    [Address]


Date: [Current Date]


RE: Freedom of Information Act Request


Dear [Agency]:


Pursuant to the Freedom of Information Act (5 U.S.C. § 552), I am requesting 

copies of the following records:


REQUEST: Any and all documents, reports, investigations, or records related to 

chemical dumping, hazardous waste disposal, or environmental contamination at or 

near Bumpus Cove Road, Erwin, Tennessee 37640 during the 1970s, including but 

not limited to:


- Incident reports

- Investigation files

- Correspondence

- Environmental assessments

- Cleanup records

- Enforcement actions

- Photographs or maps


Please provide these records in the format they are normally maintained or, if 

voluminous, provide them in reasonably accessible form.


If any portion of these records is withheld, please identify the specific exemption(s) 

claimed and provide a detailed justification.


I will pay all reasonable copying and postage costs. Please confirm receipt of 

this request and advise on expected fulfillment timeframe.


Sincerely,


[Your Name]

[Your Address]

[Your Phone]

[Your Email]

EOF

    

    log_message "FOIA template created: $foia_file"

}


# Main execution

main() {

    log_message "===== Chemical Dumping Information Search Started ====="

    log_message "Target: Bumpus Cove Rd, Erwin, TN 37640 (1970s)"

    

    # Perform searches

    search_online "Bumpus Cove Erwin Tennessee chemical dump 1970s" "google"

    search_online "Erwin TN environmental contamination history" "google"

    search_local_records

    

    # Generate helpful resources

    generate_research_guide

    create_foia_template

    

    log_message "===== Search Setup Complete ====="

    log_message "Results directory: $SEARCH_DIR"

    log_message "Review the generated guides for detailed research instructions"

}


# Run main function

main


# Display summary

echo ""

echo "=========================================="

echo "Search automation complete!"

echo "Results saved to: $SEARCH_DIR"

echo "=========================================="

echo ""

echo "Next steps:"

echo "1. Review research_guide_*.txt for comprehensive search strategies"

echo "2. Use FOIA template to request official records from agencies"

echo "3. Check EPA Superfund database: https://www.epa.gov/superfund"

echo "4. Contact Campbell County Courthouse for local records"

echo ""