cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5614
Views
0
Helpful
11
Replies

C20 - Execute API via SSH with plink logged as admin

matus.bankovic
Level 1
Level 1

Hi all,

what is the way to interact via ssh vith help of API and application plink to execute commands on a C20 looged in as admin?

I am able to execute commands as root for example to execute a reboot:

Batch script:

C:\putty\plink.exe -ssh IP_Addresss -l root -pw password -m C:\C20restartjob\c20.txt

c20.txt:

echo rebooting now

/sbin/reboot

Exit

I would like to be able to execute API commands but being logged as admin user.

What do I have to use in the c20.txt file so the command is recognized?

SW: TC 6.X

Thank you in advance for your hints.

2 Accepted Solutions

Accepted Solutions

Played a bit further - and found something that does work for plink.

     C:\>PLINK.EXE -ssh testc60 -l admin -pw TANDBERG < C20.TXT

where C20.TXT cotains:

     xcommand boot

     bye

The "bye" is really unnecessary if doing the reboot - but if you're issuing other xcommands then it's necessary to disconnect from the codec at the end of all your commands.

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

Wayne

Please remember to mark helpful responses and to set your question as answered if appropriate.

View solution in original post

Hi Matus,

Capturing the output is an easy one... where we've used the < in the command line above to take the input from a file, you can use the > to send the output to a file.

ie C:\>PLINK.EXE -ssh testc60 -l admin -pw TANDBERG < C20.TXT > OUTPUT.TXT

or to append the text to an existing file instead of making a new one, use >> instead of >.


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

Wayne

Please remember to mark helpful responses and to set your question as answered if appropriate.

View solution in original post

11 Replies 11

Patrick Sparkman
VIP Alumni
VIP Alumni

Hello Matus -

I've never heard of plink, have you tried putty?  Enter the IP address of the codec and when prompted, enter the username admin and associated password.  If the password has not been changed it's TANDBERG by default I believe.

Another option is, if you can login via root, you can type in the command tsh and access the same commands as if you were logged in as admin via SSH.

Hi Patrick,

Explanation what is plink http://en.wikipedia.org/wiki/Plink.

The goal is to automate connection and execution of commands to codecs (cca 200).

Plink is connecting in a non interactive mode and I need to find out how to execute a API command so its recognized.

I would like to execute it with connecting as admin and not root.

To be honest I would not go that way.

Btw, there is a nice port of linux commands to windows

http://cygwin.com/ that offers other nice and handy command line clients

Sure you can pipe a coule of configuration parameters or commands. Maybe you can

also handle some feedback so that you can get active if one of these fails, but form just

looking at it shortly it does not look like that. (seems to be more or less a ssh command line client).

It is possible to pipe commands through tsh, but I would not recomend it!

You have the HTTPS API to configure and control the endpoint:

http://www.cisco.com/en/US/docs/telepresence/endpoint/codec-c-series/tc6/api_reference_guide/codec_c60-c40_api_reference_guide_tc61.pdf

Its quite easty to handle (guess you can use perl python php for it or simply some command line tool like

curl, wget, ... In addition you get a result back so you can take action if some task failed.

I would go with https api access!

Please remember to rate helpful responses and identify helpful or correct answers.

Please remember to rate helpful responses and identify

Steve Kapinos
Cisco Employee
Cisco Employee

You should not be using root - you can't assume it will be enabled (it's disabled by default and not available in all modes).  Logging in as root will take you to the linux shell (not the supported API).  Logging in as another user, like the user 'admin' takes you to the Codec command reference, which has a full API.

The API is fully documented on the product information pages.  Reboot should just be 'xcommand boot'

For automation like this tho, the shell is overkill.  You can use the same commands via the XML API and just do HTTP PUT/GET to the device with the correct XML documents to drive the system. 

Tho I'd be more concerned why you are looking to automate rebooting the systems... that should not be necessary in the first place.

Wayne DeNardi
VIP Alumni
VIP Alumni

Wouldn't you just change the credentials you supply in the plink command line to the "admin" user rather than "root" as you've specified and put the correct CLI command in your C20.TXT file?  Ie, if your admin username is "admin" with password "TANDBERG", you just change the details as follows:

Batch script:

C:\putty\plink.exe -ssh IP_Addresss -l admin -pw TANDBERG -m C:\C20restartjob\c20.txt

c20.txt

xcommand boot

bye

Personally, I like to create a separate user on my codecs for these types of things rather than using the default "admin" user.

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

Wayne

Please remember to mark helpful responses and to set your question as answered if appropriate.

No that would not work, when using root you access the linux operating system.

There you can use ssh to remote execute linux commands:

$ ssh root@192.168.101.156 date

Thu Feb 20 02:14:36 CET 2014

If you would try the same with (admin or an other system user accout) it would fail:

$ ssh admin@192.168.101.156 xstatus

tsh: invalid option -- 'c'

Welcome to test

TANDBERG Codec Release TC7.0.1.264e160

SW Release Date: 2013-12-10

*r Login successful

OK

Anyhow, the https API is the way to go!

Please remember to rate helpful responses and identify helpful or correct answers.

Please remember to rate helpful responses and identify

Thanks Martin,

Yes, I am aware of the difference between logging in as "root" (and using the Linux commands) and loggin in as "admin" (and using the CLI commands).

I hadn't tried my suggestion - but have now.  I got the same result as you posted above.

Strange thing is, if you leave off the -m and command file, and just use the rest, you can type in the command manually in to the plink window atfer it connects and it all works as expected:

C:\>PLINK.EXE -ssh testc60 -l admin -pw TANDBERG

Using username "admin".


Welcome to TESTC60

TANDBERG Codec Release TC7.0.2.aecf2d9

SW Release Date: 2014-01-18

*r Login successful


OK


←[?1034h



xcommand boot

*r BootResult (status=OK):

** end


OK

CUIL reboot request, restarting

tshell: Remote closed connection


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

Wayne

Please remember to mark helpful responses and to set your question as answered if appropriate.

Played a bit further - and found something that does work for plink.

     C:\>PLINK.EXE -ssh testc60 -l admin -pw TANDBERG < C20.TXT

where C20.TXT cotains:

     xcommand boot

     bye

The "bye" is really unnecessary if doing the reboot - but if you're issuing other xcommands then it's necessary to disconnect from the codec at the end of all your commands.

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

Wayne

Please remember to mark helpful responses and to set your question as answered if appropriate.

matus.bankovic
Level 1
Level 1

Thank you all for your suggestions,

the "reboot" I mentioned at the start of the post was just an example.

@Wayne DeNardi: I tryed your solution works like a charm. (Now I try to direct the output of the executed commands into a seperate file for each codec).


@Martin Koch & Steven Kapinos : Thank you for your suggestion.

As I am new to the xml API topic I have to learn to use it. (Reading the API documentation now)

If possilble please provide a real life example how to execute xml api in background and collet info in seperate file.

Goal is to be able to pull information (executed different commands) from the codecs (save them in text file for each codec seperate file) and proceed them later.

Imagine you want to create a overview  for all codecs. If they are using a touch panel and how it is connected. (Direct mode or pairing mode)

Hi Matus,

Capturing the output is an easy one... where we've used the < in the command line above to take the input from a file, you can use the > to send the output to a file.

ie C:\>PLINK.EXE -ssh testc60 -l admin -pw TANDBERG < C20.TXT > OUTPUT.TXT

or to append the text to an existing file instead of making a new one, use >> instead of >.


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

Wayne

Please remember to mark helpful responses and to set your question as answered if appropriate.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: