INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Issuing commands from telnet  (Read 10430 times)

nieldm

  • Recent member
  • *
  • Posts: 15
Issuing commands from telnet
« on: January 10, 2014, 11:32:20 am »

Hi,

First post here...apologies if I have missed something glaringly obvious but I have tried to do my homework before posting.

I am considering developing a module to allow MC to be controlled from a Crestron system. In order to be able to do that I need to be able to open a TCP/IP socket and issue commands, pretty much as one would do from a Telnet session, and parse the feedback received.

I have scanned the Wiki with respect to issuing commands from the command line and have no issues there and have read the article regarding playing music across a network, although that is focused on controlling one instance of MC from another, as far as I can tell.

To get started, I can telnet into my MC server on port 52199 but what I am struggling with is how to issue commands from the telnet session; clearly I can't preface those commands with "mcXX.exe". Is there some documentation somewhere that I have missed, such as that used by the existing third party remote control developers such as Gizmo?

Marc
Logged

nieldm

  • Recent member
  • *
  • Posts: 15
Re: Issuing commands from telnet
« Reply #1 on: January 10, 2014, 12:16:13 pm »

Belay the above, I just found the developer section of the Wiki.....

Noobs huh? Never RTFM.....
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Issuing commands from telnet
« Reply #2 on: January 10, 2014, 01:09:14 pm »

For most things, you'll want to use the MCWS REST interface.  With Media Network enabled, go to:

    http://localhost:52199

or more specifically:

   http://192.168.2.20:52199/MCWS/v1/

and see the examples there.
Logged
The opinions I express represent my own folly.

nieldm

  • Recent member
  • *
  • Posts: 15
Re: Issuing commands from telnet
« Reply #3 on: January 10, 2014, 02:10:56 pm »

Thanks. Whilst the Dev wiki is helpful, and I can issue commands easily via web services, as far as I can tell the examples on the examples relate to feedback as opposed to sending commands.

I am almost certainly being dumb here, but if, for example, I have connected to my (Mac based) server using telnet, how do I send a command? Anything I try results in a response as follows:

MNmBP:~ Marc$ telnet 192.168.0.8 52199
Trying 192.168.0.8...
Connected to 192.168.0.8.
Escape character is '^]'.
GetNumberFiles()^@
HTTP/1.1 501 Server Error
Server: Darwin, UPnP/1.1 DLNADOC/1.50, JRiver/18
Date: Fri, 10 Jan 2014 18:27:28 GMT

Connection closed by foreign host.

No matter what I try, I get the same response. It could be, of course, that sending commands via telnet isn's supported but that would surprise me.

Marc

Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Issuing commands from telnet
« Reply #4 on: January 10, 2014, 02:16:45 pm »

telnet is just a simple protocol which allows you to connect to remote services.  However, while you can connect, you can't just "talk" to the remote service in any fashion you wish.  Like humans, you must speak their expected language and use their protocol.  The MCWS interface and other services supported by Media Network expect certain HELLOs to be performed, and using a particular protocol; otherwise, they ignore you and drop the connection (just like a human would if you started speaking gibberish).

That's why I suggest you don't want to use telnet, and instead want to use curl, or wget, or your specific scripting languages support for HTTP conversations.

Instead, use an HTTP client if you want to use MCWS (or WebGizmo).  Web clients will handle much of the conversational protocol, and your only job then is to ask the right questions.

I use MCWS frequently to send commands as well as to retrieve information.

Maybe a specific question or two might help...
Logged
The opinions I express represent my own folly.

nieldm

  • Recent member
  • *
  • Posts: 15
Re: Issuing commands from telnet
« Reply #5 on: January 10, 2014, 02:28:24 pm »

I understand what telnet is, what it's purpose is and how to talk to remote services; I develop control systems interfaces for a living but am new to JRiver. Maybe me posting the telnet conversation led you to believe that I don't "get it", my mistake for posting it!

Where did you suggest I shouldn't use telnet? Apologies if I missed that.

I would prefer not to use web services if at all possible, but can if it is the only option available. Are you saying there is no way of sending commands to the server that don't involve either invoking a .exe or sending a http://... string?

Marc
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Issuing commands from telnet
« Reply #6 on: January 10, 2014, 02:33:13 pm »

I'd confused some portion of your request here with another thread where I suggested wget, curl, etc.  But no matter.

You can develop a COM-based plugin but that's for Windows.

The other options for talking to MC are:

   - the command line (options or indirectly via MCC)
   - MCWS
Logged
The opinions I express represent my own folly.

nieldm

  • Recent member
  • *
  • Posts: 15
Re: Issuing commands from telnet
« Reply #7 on: January 10, 2014, 02:39:04 pm »

OK we are getting somewhere.

How to do talk to the server via the command like from OSX without a .exe? I can do it successfully from Windows but I am missing how this can be achieved from a Mac. As you are suspecting, a COM plugin is what I would prefer, but it seems to be a no go.

To clarify, I am simply trying to write something for home use via Crestron and my music server is on a Mac Mini. This isn't commercial.

Once again, apologies if I missed some documentation somewhere.

Thanks again
Marc
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Issuing commands from telnet
« Reply #8 on: January 10, 2014, 02:51:32 pm »

See:

   http://wiki.jriver.com/index.php/Media_Center_Core_Commands
   http://wiki.jriver.com/index.php/The_Command_Line

But also see the caveat (which is the thread I'd confused with this one, since you were the same poster):

   http://yabb.jriver.com/interact/index.php?topic=85972.0

What language are you writing your script in ?
Logged
The opinions I express represent my own folly.

nieldm

  • Recent member
  • *
  • Posts: 15
Re: Issuing commands from telnet
« Reply #9 on: January 10, 2014, 03:00:38 pm »

It's called SIMPL+, which is proprietary to Crestron, but not dissimilar to C++. I can issue HTTP POST commands via SIMPL+, I would just prefer not to were there an alternative, but I am suspecting there isn't.

I only just read you reply on the other thread and am joining the dots.....
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Issuing commands from telnet
« Reply #10 on: January 10, 2014, 03:04:43 pm »

Got it.  To send commands which write data, you're going to need Authentication enabled, and therefore your language will need to support both writing cookies and sending AUTH information.
Logged
The opinions I express represent my own folly.

nieldm

  • Recent member
  • *
  • Posts: 15
Re: Issuing commands from telnet
« Reply #11 on: January 10, 2014, 03:18:36 pm »

I don't think I want to write data, simply send commands such as "give me all albums by artist {X}" and be able to put the response into the appropriate arrays and display them on a touchpanel, select one, and so on. From my WS explorations I can see that I can parse the feedback but it's the sending of the commands that is my question.

As I said, if my only option is http, so be it.



Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Issuing commands from telnet
« Reply #12 on: January 10, 2014, 03:41:47 pm »

See my script in this thread for an example:

    http://yabb.jriver.com/interact/index.php?topic=85990.0
Logged
The opinions I express represent my own folly.

nieldm

  • Recent member
  • *
  • Posts: 15
Re: Issuing commands from telnet
« Reply #13 on: January 10, 2014, 04:46:21 pm »

Interesting stuff, thank you. I need some time to absorb it!
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72438
  • Where did I put my teeth?
Re: Issuing commands from telnet
« Reply #14 on: January 10, 2014, 05:42:32 pm »

Keep us posted on Crestron.  We'd like to provide better support for it.
Logged

nieldm

  • Recent member
  • *
  • Posts: 15
Re: Issuing commands from telnet
« Reply #15 on: January 11, 2014, 09:43:22 am »

It's actually not too difficult, I have a stable connection to my MC from my Crestron processor, can issue commands using web services and the feedback is being received on the "rx$" signal.

The time consuming part will be parsing the XML feedback but all eminently doable. It would be better (or easier..) were there a scripting language as opposed to having to build reasonably complex web service command strings (eg the command for the Values/All Artists command is : "GET /MCWS/v1/Library/Values?Field=Artist  HTTP/1.1\nhost: 192.168.0.8\n\n" ... a little cumbersome). Crestron and web services don't co-exist in as straightforward a manner as they could.

I will keep you posted as I build the module.
Logged
Pages: [1]   Go Up