Automation of command(s) to NI/NX controllers via telnet/SSH

martingmarting Junior MemberPosts: 16
Hi all,

Been trying to figure out a way to automatically send one or more (ideally more) commands to a controller via telnet/SSH. Putty and its brother plink are both supposed to support this. However, when I try the commands that are supposed to work:

putty [controller] -ssh -l administrator -pw [password] -m asdf.txt (where asdf.txt has one or more commands)
plink [controller] -ssh -l administrator -pw [password] [AMX_telnet_command]

...I get no love:

FATAL ERROR: Server refused to start a shell/command


Any ideas on what can be done to make this work? Also open to other solutions that would let me do this.

Comments

  • travistravis Junior Member Posts: 180
    Haven't tried this yet, but it works well for other stuff...

    https://github.com/ansible/ansible

    Let us know when you get the profiles all written!
  • martingmarting Junior Member Posts: 16
    travis wrote: »
    Haven't tried this yet, but it works well for other stuff...

    https://github.com/ansible/ansible

    That seems awfully heavy for what I'm trying to do. Especially since we're Windows-based and the Ansible control system has to be Linux.


    I had limited success with the following:

    ECHO [AMX_telnet_command] | plink [controller] -ssh -l administrator -pw [password]

    This works for sending a single command to an NI (i.e. reboot). Unfortunately, on the NXes, it doesn't even work for that... Still playing around with and open to other options if anyone has suggestions!
  • ericmedleyericmedley Senior Member - 4000+ posts Posts: 4,159
    Perhaps another approach would be to write your own telnet port from within the Netlinx program. That way you can easily manage the API
  • cmatkincmatkin Senior Member Posts: 86
    Hi Marting, give Indigo Terminal Emulator from http://www.shadeblue.com a go. This has commands, macros and events.
  • mstocummstocum Junior Member Posts: 119
    If you're handy with the command line from a Unix system, look at the "expect" command.
  • martingmarting Junior Member Posts: 16
    KiTTY!

    I was able to do what I need using KiTTY which is based on a fork of putty (www.9bis.net/kitty/).

    Examples

    Rebooting a controller:
    kitty [hostname] -ssh -l [username] -pw [password] -cmd reboot

    Wiping the URL list on a controller (up to 10 entries):
    kitty [hostname] -ssh -l [username] -pw [password] -cmd "set url\nD\nD\nD\nD\nD\nD\nD\nD\nD\nD\n"
  • a_riot42a_riot42 AMX Wizard Posts: 1,619
    I was doing something similar a while ago telnetting into touch panels, and sending a command, parsing its output, and then displaying it on the panel. I used this to get the time until the battery died, which was only available using the batt command at the touch panel shell. This was from code though, not from a laptop. My suggestion would be to FTP the text file of commands to the master, then start a telnet session in code to the master, and run each command, parsing output if needed. I haven't tried it on a master, but for the panels it worked, so I don't see why it wouldn't on a master. That is only one way, I'm sure there are many others.
    Paul
Sign In or Register to comment.