Skip to content
Advertisement

Automatically close PuTTY when connection is lost

I have a script in bash, running multiple PuTTY sessions. For example, I open the connection to run a couple of commands, when it finishes it saves the values, closes the session, opens a new session and runs a couple more.

This script is supposed to run for 60 hours, more or less, so i need to have everything automated.

My issue is, when the PuTTY session is open, and connected to the device i need, if at some point the device reboots (don’t know why it reboots, it just does), a window in putty appears saying the connection was terminated (obviously). The problem is that the window stays open until I press the “ok” button. So my script just stops there until some manual interaction with the PuTTY session.

Is there a way to automatically terminate the PuTTY session if a disconnection happens?

Thank you for your help, if you need some more information just let me know! regards

Advertisement

Answer

PuTTY is not intended for automation.

Use PLink (PuTTY command-line tool). It’s a console application, with the same command line arguments as PuTTY, so the transition should be easy.


Though setting “Close window on exit” to “Always” does work (even if you claim it does not).

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement