fix: Preserve CRLF line endings in DOS BAT files during sync
Critical fix for DOS 6.22 compatibility - CRLF line endings were being converted to LF during AD2-to-NAS sync, causing BAT files to fail on DOS. Root Cause: - OpenSSH scp uses SFTP protocol by default (text mode) - SFTP converts line endings (CRLF → LF) - DOS 6.22 requires CRLF for batch file execution Solution - Fixed AD2 Sync Script: - Added -O flag to scp commands in Sync-FromNAS.ps1 - Forces legacy SCP protocol (binary mode) - Preserves CRLF line endings during transfer Created deployment scripts: - fix-ad2-scp-line-endings.ps1: Updates Sync-FromNAS.ps1 with -O flag - deploy-all-bat-files.ps1: Deploy 6 BAT files to AD2 (UPDATE, NWTOC, CTONW, CHECKUPD, REBOOT, DEPLOY) - deploy-bat-to-nas-direct.ps1: Direct SCP to NAS with -O flag for immediate testing - verify-nas-crlf.ps1: Validates CRLF preservation on NAS Created diagnostic scripts: - check-line-endings.ps1: Compare original vs NAS file line endings - check-ad2-sync-log.ps1: Monitor sync log on AD2 - check-ad2-bat-files.ps1: Verify files on AD2 - check-scp-commands.ps1: Analyze SCP command usage - trigger-ad2-sync-now.ps1: Manual sync trigger for testing Verification: - DEPLOY.BAT: 9,753 bytes with CRLF (was 9,408 bytes with LF) - All 6 BAT files deployed to NAS with CRLF preserved - DOS machines can now execute batch files from T:\ Files deployed: - DEPLOY.BAT (one-time installer) - UPDATE.BAT (backup utility) - NWTOC.BAT (network to computer updates) - CTONW.BAT (computer to network uploads) - CHECKUPD.BAT (check for updates) - REBOOT.BAT (reboot utility) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
55
deploy-bat-to-nas-direct.ps1
Normal file
55
deploy-bat-to-nas-direct.ps1
Normal file
@@ -0,0 +1,55 @@
|
||||
# Deploy BAT files directly to NAS with CRLF preservation
|
||||
|
||||
$BATFiles = @(
|
||||
"DEPLOY.BAT",
|
||||
"UPDATE.BAT",
|
||||
"NWTOC.BAT",
|
||||
"CTONW.BAT",
|
||||
"CHECKUPD.BAT",
|
||||
"REBOOT.BAT"
|
||||
)
|
||||
|
||||
Write-Host "[INFO] Deploying BAT files directly to NAS..."
|
||||
Write-Host "[INFO] Using SCP with -O flag (binary mode, preserves CRLF)"
|
||||
Write-Host ""
|
||||
|
||||
$SuccessCount = 0
|
||||
$TotalFiles = 0
|
||||
|
||||
foreach ($File in $BATFiles) {
|
||||
if (Test-Path $File) {
|
||||
Write-Host " Deploying: $File"
|
||||
|
||||
# Verify CRLF before sending
|
||||
$Content = Get-Content $File -Raw
|
||||
if ($Content -match "`r`n") {
|
||||
$Size = (Get-Item $File).Length
|
||||
Write-Host " Size: $Size bytes (with CRLF)"
|
||||
|
||||
# Copy to NAS root (/data/test/)
|
||||
$result = & 'C:\Windows\System32\OpenSSH\scp.exe' -O $File root@192.168.0.9:/data/test/ 2>&1
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host " [SUCCESS] Copied to /data/test/$File"
|
||||
$SuccessCount++
|
||||
} else {
|
||||
Write-Host " [ERROR] Failed: $result"
|
||||
}
|
||||
} else {
|
||||
Write-Host " [ERROR] No CRLF found - skipping"
|
||||
}
|
||||
|
||||
$TotalFiles++
|
||||
Write-Host ""
|
||||
} else {
|
||||
Write-Host " [WARNING] $File not found"
|
||||
Write-Host ""
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "[COMPLETE] Direct deployment to NAS"
|
||||
Write-Host " Files processed: $TotalFiles"
|
||||
Write-Host " Files deployed: $SuccessCount"
|
||||
Write-Host ""
|
||||
Write-Host "[INFO] Files are now available at T:\ for DOS machines"
|
||||
Write-Host "[INFO] Test DEPLOY.BAT on a DOS machine to verify CRLF"
|
||||
Reference in New Issue
Block a user