Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Community Member

Script action on SX-20

Has anyone ever been able to write a Python script that will connect and sumit an command over SSH?

Everyone's tags (1)
4 REPLIES
VIP Purple

I haven't done if via a

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.

Wayne
--
Please remember to rate responses and to mark your question as answered if appropriate.
Community Member

Thank you for your response,

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.

VIP Purple

There really isn't any

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.

Wayne
--
Please remember to rate responses and to mark your question as answered if appropriate.
Community Member

Maybe I am a little late to

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

250
Views
3
Helpful
4
Replies
CreatePlease to create content