0

I'm partly new to Automator and since there is no application for Mac to control my Pioneer AVR I use some commands in the Terminal. But I'd like to automate some of my commands with the terminal. I have to say that I don't know much about the Terminal and Networking. But I know that it's not so easy in Automator or in Xcode (with swift) like in the Terminal. In the Terminal I use this code:

telnet vsx-923.fritz.box.

Response:

Trying 123.456.789.10...
Connected to vsx-923.fritz.box.
Escape character is '^]'.
BridgeCo AG Telnet server


vd //which means Volume down

Response:

FL004D2E564F4C20202D33302E356442
VOL100

In Automator in the Shell-Script I typed

telnet vsx-923.fritz.box.
vd

Where I got the error "Connection closed by foreign host." In a forum I found out that I had to use echo why I get a response now. But If I type in

telnet vsx-923.fritz.box.
echo 'vd'

I only get the response that the avr is connected but for the Volume I don't get a response.

In the future hopefully I am able to build an application, but for now It'll be enough to make it this way. I hope you can help me with the solution. Here you get the PDF of the pioneer commands if you'd like to have them. http://www.pioneerelectronics.com/StaticFiles/PUSA/Files/Home%20Custom%20Install/VSX-1120-K-RS232.PDF

Thanks in advance.

Jonas

2 Answers 2

0

Your command vd you are sending obviously requires a CR-LF at the end of the line.

I would not recommend using telnet - instead, use netcat:

echo vd | nc -c vsx-923.fritz.box 23

nc -csends CR-LF at the line ending.

5
  • Thank you for your Answer. It works very well for me. But what means CR-LF and this letter: '|'? Sep 15, 2015 at 18:43
  • CR-LF = Carriage Return - Line Feed and '|' is the Unix Pipe symbol. Sep 16, 2015 at 10:02
  • @JonasNelson | will pipe the output of one command to the input of the next. It's sort of like the first command is nc -c vsx-923.fritz.box 23; followed by vd, because that is the output produced by echo vd. To understand it better, try typing the commands on either side of the pipe (aka |) seperately. That ought to demonstrate the relationship.
    – voices
    Sep 16, 2015 at 16:12
  • @JonasNelson Also, I'm pretty sure that telnet would work fine for this. You might want to check with @Garex.
    – voices
    Sep 16, 2015 at 18:00
  • I discourage telnet as it is some sort of deprecated. U/PW is transmitted to the telnet server in clear text. For that, if you have services to connect to where you do not need U/PW authorization, you could also use netcat. Second, netcat offers more options in handling scripted connections than telnet does, e.g. separation of message, errors and return code (output channel 1 (=STDOUT) and channel 2 (STDERR) and $?). netcat is still more powerful (see man nc in your favourite terminal emulation). Sep 21, 2015 at 7:59
0

Incorporating Automator might be unnecessary for what you're trying to achieve. Perhaps it would be more suitable to just write a bash shell script. If you've never written a bash shell script before, it's easy to get started. You can simply type out the commands exactly how you've already demonstrated, but into some kind of text editor or notepad software, and save it with an .sh extension on the end.

When I first started learning about this stuff years ago I found nano to be a quick and easy text editor for learning and writing new material. If you want to give it a try you can start by just typing nano in the terminal.

If necessary, you can grant executive permission with:

chmod +x ./example.sh

Let me know if this helps put you on the right track or not. If not, we can just try something else. Also, if you want/need you can reply here or contact me privately via chat.

3
  • I tested it with the .sh ending, but how do I open this file? I tested nano but I don't like it somehow. So sadly it didn't put me on the right track :( But I got a solution from Garex. But nevertheless thank you! Sep 15, 2015 at 18:37
  • If you're relatively new to the command line you're probably not going to like any of its text editors. However, there are others. nano is similar to the original pico. Some popular alternatives are vi, vim & emacs. These are generally considered to be quite powerful but can represent a learning curve. You don't have to use any of these. You can use any GUI text editing application (i.e. TextEdit.app) that allows saving in plaintext. FYI: this option should be available in the Format drop down menu.
    – voices
    Sep 16, 2015 at 16:54
  • @JonasNelson To run the script, you should just be able to right-click (select Open With) on the icon it creates. By default nano will save files to $HOME aka /Users/Jonas/, or something similar. This is usually the default working directory when you open Terminal.app. So, if/when you're in the directory where the *.sh file is saved, you can type: ./example.sh (you must include the . and the / prepending the filename) to execute it. If you saved it elsewhere, like on your desktop for example, you can do: ./Desktop/example.sh, or simply, Desktop/example.sh, to do the same.
    – voices
    Sep 16, 2015 at 18:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .