
#!/bin/bash

gzFile="$1"
outputFile="$2"


#gzFile="/var/www/html/logserver_client/CSV/IshanCGNAT-2025-04-17_01:30:03.gz"
#outputFile="/var/www/html/logserver_client/CSV/IshanCGNAT-2025-04-17_01:30.csv"
if [ -f "$gzFile" ]; then
    echo "Extracting $gzFile to $outputFile..."

    # Run and capture error output too
    gunzip -d -c "$gzFile" > "$outputFile" 2> /var/www/html/logserver_client/CSV/gunzip_error.log

    if [ $? -eq 0 ]; then
        echo "✅ Extracted successfully to: $outputFile"
        exit 0
    else
        echo "❌ Extraction failed. Error log:"
        cat /tmp/gunzip_error.log
        exit 1
    fi
else
    echo "❌ File not found: $gzFile"
    exit 2
fi

