ncssar / radiolog

SAR radio log program
Other
13 stars 3 forks source link

powershell backup rotation script - space in path causes non-fatal error each time #643

Closed caver456 closed 1 year ago

caver456 commented 1 year ago

The space in the path shows an error similar to '(x86) is not a command name'. See screenshot if needed. Not high priority because the operator probably doesn't even notice, and the backups have rarely ever been used.

caver456 commented 1 year ago

From the transcript - note this is another case where development doesn't illustrate the bug but an installed version does:

061303:Invoking backup rotation script: powershell.exe -ExecutionPolicy Bypass C:\Program Files (x86)\RadioLog\rotateCsvBackups.ps1 -filenames  """C:\Users\caver\RadioLog\New_Incident_2023_03_14_061254\New_Incident_2023_03_14_061254.csv""","""C:\Users\caver\RadioLog\New_Incident_2023_03_14_061254\New_Incident_2023_03_14_061254_clueLog.csv""","""C:\Users\caver\RadioLog\New_Incident_2023_03_14_061254\radiolog_fleetsync.csv""","""C:\Users\caver\RadioLog-2WD\New_Incident_2023_03_14_061254.csv""","""C:\Users\caver\RadioLog-2WD\New_Incident_2023_03_14_061254_clueLog.csv""","""C:\Users\caver\RadioLog-2WD\radiolog_fleetsync.csv"""
061303:Accepted2
061304:  writing C:\Users\caver\RadioLog\New_Incident_2023_03_14_061254\New_Incident_2023_03_14_061254.csv
061304:  done writing C:\Users\caver\RadioLog\New_Incident_2023_03_14_061254\New_Incident_2023_03_14_061254.csv
061304:  writing C:\Users\caver\RadioLog-2WD\New_Incident_2023_03_14_061254.csv
061304:  done writing C:\Users\caver\RadioLog-2WD\New_Incident_2023_03_14_061254.csv
061304:  writing C:\Users\caver\RadioLog\New_Incident_2023_03_14_061254\New_Incident_2023_03_14_061254_clueLog.csv
061304:  done writing C:\Users\caver\RadioLog\New_Incident_2023_03_14_061254\New_Incident_2023_03_14_061254_clueLog.csv
061304:  writing C:\Users\caver\RadioLog-2WD\New_Incident_2023_03_14_061254_clueLog.csv
061304:  done writing C:\Users\caver\RadioLog-2WD\New_Incident_2023_03_14_061254_clueLog.csv
x86 : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:19
+ C:\Program Files (x86)\RadioLog\rotateCsvBackups.ps1 -filenames "C:\U ...
+                   ~~~
    + CategoryInfo          : ObjectNotFound: (x86:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
caver456 commented 1 year ago

Two-part solution: 1) build an argument list for Popen, rather than a single string; spaces are handled correctly and there's no need to wrap arguments in triple-double-quotes 2) use the '-File' powershell argument right before the script name - this allows handling of spaces in the script name