Exscript: How to switch between interactive and non-interactive sessions?

I try to programmatically open a session with a Unix server, and then release the control to the user script before pressing Ctrl + y, after which the program should take control I use Eclipse and WinPython 2.7. here is the code

from Exscript.util.interact import read_login from Exscript.protocols import SSH2 def Test (): print "Interactive session closed" account = read_login() # Prompt the user for his name and password conn = SSH2() conn.set_driver('generic') # We choose to use SSH2 conn.connect('remmotehostip') # Open the SSH connection conn.login(account) # Authenticate on the remote host conn.execute('uname -a') # Execute the "uname -a" command print conn.response conn.interact({'\031': Test()}) conn.send('exit\r') # Send the "exit" command conn.close() 

above is not satisfied with

  Traceback (most recent call last): File "C:\Users\mynamehere\Documents\Eclipse\ESNetworkDiscovery\TestInteractiveSession.py", line 20, in <module> conn.interact({'\031': Test()}) File "C:\Utils\WPy2.7-32\python-2.7.13\lib\site-packages\Exscript\protocols\SSH2.py", line 364, in interact return self._open_shell(self.shell, key_handlers, handle_window_size) File "C:\Utils\WPy2.7-32\python-2.7.13\lib\site-packages\Exscript\protocols\Protocol.py", line 1190, in _open_shell return self._open_windows_shell(channel, key_handlers, handle_window_size) TypeError: _open_windows_shell() takes exactly 3 arguments (4 given) 

What am I doing wrong?

+5
source share
1 answer

Looks like an error in Exscript.

From Protocol.py :

  return self._open_windows_shell(channel, key_handlers, handle_window_size) ... def _open_windows_shell(self, channel, key_handlers): 

This function does not accept argument 4 handle_window_size ( careful about how python counts arguments in this situation ).

Apparently you are not using the latest version, but even the latest one has an error, as far as I can tell. Looking through the source story, I would say that the error was introduced in version 2.2, it is not in 2.1. I have not tested it, just read the source and I am not a python expert, so I could be completely wrong.

If I'm right, you can’t do much except:

  • using 2.1 (which is apparently 7 years old)
  • the fix is ​​local (maybe remove the last argument ... not sure if this will work!)
  • filing problems
+2
source

Source: https://habr.com/ru/post/1273529/


All Articles