Files
claudetools/quick-sync-check.ps1
Mike Swanson 925a769786 fix: Replace NUL device references with DOS 6.22 compatible tests
Critical fix for DOS 6.22 compatibility - NUL is a reserved device name
in both DOS and Windows and cannot be used as a file/directory name.

Problem:
- "T: 2>NUL" attempts to create a file called "NUL" (not allowed)
- "IF NOT EXIST T:\NUL" tests for NUL device (unreliable)
- "IF NOT EXIST path\NUL" treats NUL as filename (invalid)

Solution - Replaced with proper DOS 6.22 tests:
- "T: 2>NUL" → "DIR T:\ >nul" (test drive access via directory listing)
- "IF NOT EXIST T:\NUL" → "IF NOT EXIST T:\*.*" (test for any files)
- "IF NOT EXIST path\NUL" → "IF NOT EXIST path\*.*" (test directory)

Note: Using lowercase "nul" for output redirection is acceptable as
it redirects to the NUL device, but NUL as a filename/path is invalid.

Files updated:
- DEPLOY.BAT: Fixed drive and directory tests
- UPDATE.BAT: Fixed drive and directory tests
- NWTOC.BAT: Fixed drive and directory tests
- CTONW.BAT: Fixed drive and directory tests
- CHECKUPD.BAT: Fixed drive and directory tests
- DOSTEST.BAT: Fixed drive and directory tests

Created fix-nul-references.ps1:
- Automated script to find and fix NUL references
- Preserves CRLF line endings
- Updates all BAT files consistently

Created monitoring scripts:
- monitor-sync-status.ps1: Periodic sync monitoring
- quick-sync-check.ps1: Quick AD2-to-NAS sync status check

Verification:
- All BAT files maintain CRLF line terminators
- File sizes increased slightly (4-8 bytes) due to pattern changes
- DOS 6.22 compatible wildcard tests (*.*) used throughout

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 16:41:31 -07:00

60 lines
2.0 KiB
PowerShell

# Quick sync status check
$Username = "INTRANET\sysadmin"
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential($Username, $Password)
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Sync Status Check - $(Get-Date -Format 'HH:mm:ss')" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# Check AD2 sync log
Write-Host "[INFO] Recent sync activity on AD2:"
try {
$LogTail = Invoke-Command -ComputerName 192.168.0.6 -Credential $Cred -ScriptBlock {
Get-Content 'C:\Shares\test\scripts\sync-from-nas.log' -Tail 15
}
$LogTail | ForEach-Object { Write-Host " $_" }
} catch {
Write-Host " [ERROR] Could not read log: $_" -ForegroundColor Red
}
Write-Host ""
Write-Host "[INFO] Checking DEPLOY.BAT on NAS:"
# Check file on NAS
$NASInfo = & 'C:\Windows\System32\OpenSSH\ssh.exe' -o BatchMode=yes root@192.168.0.9 'ls -lh /data/test/DEPLOY.BAT' 2>&1
Write-Host " $NASInfo"
# Verify CRLF
& 'C:\Windows\System32\OpenSSH\scp.exe' -O root@192.168.0.9:/data/test/DEPLOY.BAT ./DEPLOY_CHECK.BAT 2>$null
if (Test-Path "DEPLOY_CHECK.BAT") {
$Content = Get-Content "DEPLOY_CHECK.BAT" -Raw
$Size = (Get-Item "DEPLOY_CHECK.BAT").Length
$OrigSize = (Get-Item "DEPLOY.BAT").Length
Write-Host ""
Write-Host "[INFO] CRLF Verification:"
Write-Host " Original size: $OrigSize bytes"
Write-Host " NAS copy size: $Size bytes"
if ($Content -match "`r`n") {
Write-Host " [SUCCESS] CRLF preserved!" -ForegroundColor Green
} else {
Write-Host " [WARNING] LF only - CRLF not preserved" -ForegroundColor Yellow
}
if ($Size -eq $OrigSize) {
Write-Host " [OK] Sizes match" -ForegroundColor Green
} else {
Write-Host " [WARNING] Size mismatch" -ForegroundColor Yellow
}
Remove-Item "DEPLOY_CHECK.BAT" -Force
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan