• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

python and Pxssh

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I am using pxssh for SSH connection in Python. [here the example http://www.pythonforbeginners.com/code-snippets-source-code/ssh-connection-with-python
It work fine for me when i connect to a remote Unix machine with prompt "$". My problem is that now i need to connect a server with different prompt, specifically it use 2 prompts. I want to send the prompt manually but nothing work.
I read the documentation and explain some ways to do something similar but its not working for me.! They don't have an example. For example in the next code:


I did the these changes:


What is wrong?
Also i modify the "pxssh.py" the lines:

In modified "original_prompt=r"[#$]" for "original_prompt=r"[><#$]"
and
self.UNIQUE_PROMPT = "\[PEXPECT\][\$\#] " for self.UNIQUE_PROMPT = "\[PEXPECT\][\<\>\$\#] "

Thanks
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

jhon masco wrote:
I read the documentation and explain some ways to do something similar but its not working for me.!



So what is it doing that you don't expect?
Have you checked all the return values and exceptions to see if you can figure out what exactly is failing? Looking at the documentation, I would assume the regular expression you are using for PROMPT is faulty. What is the prompt on the remote system if you log in with ssh?
 
jhon masco
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I received this exception:

File "/home/jhon/PYTHON/pssh.py", line 6, in <module>
if not s.login ('172.31.116.167', 'usuario', 'mi_password', auto_prompt_reset=False):
File "/usr/lib/python2.7/dist-packages/pexpect/pxssh.py", line 315, in login
raise ExceptionPxssh ('could not synchronize with original prompt')
pexpect.pxssh.ExceptionPxssh: could not synchronize with original prompt


The prompt that i need to set is ">" and "<" below an output example:

c:\winnt\profiles\TRAFICO>mml
WO 63 03015103 AD-638 TIME 150128 0856 PAGE 1
<exit;

c:\winnt\profiles\TRAFICO>


I figure that there is a stranger character before the prompt but i am not sure if it relevant.
The documentation in the login meth section explain how set diferent prompt but its not working for me.

Thanks
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic