03-24-2014 12:21 PM - edited 03-18-2019 02:46 AM
Has anyone ever been able to write a Python script that will connect and sumit an command over SSH?
03-24-2014 06:10 PM
I haven't done if via a Python script, but I have done some scripts over ssh before from a DOS command line using the PuTTY PLINK.EXE. You can also use telnet, a serial connection or HTTP/HTTPS to pass the commands to the codec.
The commands (and connection methods) are all documented in the API Reference Guide.
Wayne
--
Please remember to rate responses and to mark your question as answered if appropriate.
Please remember to mark helpful responses and to set your question as answered if appropriate.
03-25-2014 07:54 AM
Thank you for your response, but I the limitations that I am under require me to use Python for this.
The funny thing is that I do this via Python for other equipment, but it just does not seem to work with the CISCO endpoints for whatever reason. I figure that there must be something different about the process when CISCO is involved...but I don't know what it is.
03-25-2014 05:49 PM
There really isn't any difference on the Cisco SX20 endpoints than any other equipment (they're effectively just a Linux device).
Have you checked that ssh is enabled on the SX20?
Are you using the correct username and password?
Can you manually ssh to the codec from the box you are trying to connect to via Python (or are there network connectivity issues)?
Are you able to try telnet rather than ssh? (as a test).
Wayne
--
Please remember to rate responses and to mark your question as answered if appropriate.
Please remember to mark helpful responses and to set your question as answered if appropriate.
11-04-2014 04:20 AM
Maybe I am a little late to this party here but I have something that can help you out. I was searching myself to find a way to get this to be easier to manage and found this method.
#!/usr/bin/env python
import pxssh
import getpass
try:
s = pxssh.pxssh(timeout=1, maxread=2000000)
s.force_password = True
hostname = raw_input('hostname: ')
username = raw_input('username: ')
password = getpass.getpass('password: ')
s.PROMPT= 'SSH> '
s.login (hostname, username, password, auto_prompt_reset=False)
s.prompt()
s.sendline('xConfiguration Conference 1 AutoAnswer Mode: On')
s.prompt()
s.sendline('xConfiguration Conference 1 DefaultCall Rate: 2000')
s.prompt()
data = s.before
print data
s.sendline('bye')
except pxssh.ExceptionPxssh, e:
print "pxssh failed on login."
print str(e)
You can modify the "xConfiguration" part to your liking. You can probably even make it a variable. I have before but figured you probably at least understand the basics of python and could figure it out.
Goodluck!
Gabe
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide