diff --git a/lslsh.py b/lslsh.py index ddc702a..e2d930d 100644 --- a/lslsh.py +++ b/lslsh.py @@ -67,6 +67,13 @@ class Shell(cmd.Cmd): def do_exit(self, arg): """Exit the shell.""" print("") + if self.url: + self.do_disconnect(None) + + return True + + def do_disconnect(self, arg): + """Disconnect from remote.""" if self.url: result = self.send_cmd(self.url, "disconnect") if result.get("result") == "disconnected": @@ -74,7 +81,9 @@ class Shell(cmd.Cmd): else: print("Disconnected from remote (without acknowledgement).") - return True + url = None + else: + print("Error: Not connected to remote.") def add_cmd(self, name, help_text): """Make a new command available within the shell."""