Differences
This shows you the differences between the selected revisions of the page.
guide_debugging_script 2023-01-20 | guide_debugging_script (current) | ||
Line 1: | Line 1: | ||
- | ====== Debugging WinSCP scripts and batch files ====== | ||
- | This article summarizes useful techniques when debugging non-working [[scripting|WinSCP scripts]] and batch files. | ||
- | ===== Session Logging ===== | ||
- | When using WinSCP scripting, even if it works currently, you always should have session logging enabled. To enable logging, add [[commandline#logging|''/log'' switch to WinSCP command-line]]. | ||
- | |||
- | <code batch> | ||
- | winscp.com /ini=nul /script=script.txt /log=script.log | ||
- | </code> | ||
- | |||
- | The log file includes useful information for most problems you can encounter with WinSCP. | ||
- | |||
- | ===== Inspecting Console Output ===== | ||
- | In rare case when WinSCP fails even before a session starts, the session log file is not produced. In this case the errors will display on WinSCP console output. | ||
- | |||
- | If you run WinSCP or wrapper batch file directly from Windows Explorer, the console window will close very quickly, so you might not be able to read the output. | ||
- | |||
- | When debugging script, it always better to use a console window, like Windows Command prompt or PowerShell. Additionally, use [[executables#winscp.com|''winscp.com'' console interface tool]] to run the script, as it (contrary to ''winscp.exe'') outputs to the same console window, where it was started from. | ||
- | |||
- | &screenshotpict(scripting_debugging) | ||
- | |||
- | Alternatively, when using a batch file, you can add [[https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pause|''pause'' command]] to its end to prevent the console window from closing immediately. | ||
- | |||
- | <code batch> | ||
- | winscp.com /ini=nul /script=script.txt /log=script.log | ||
- | pause | ||
- | </code> | ||
- | |||
- | ===== Further Reading ===== | ||
- | |||
- | * [[faq_batch_file|*]] | ||
- | * [[guide_debugging_scheduler|*]] | ||
- | * [[faq_environment|*]] | ||
- | * [[faq_script_vs_gui|*]] |