NetXMS Support Forum

Please login or register.

Login with username, password and session length

Author Topic: scripting and ssh commands  (Read 154 times)

Egert143

  • Newbie
  • *
  • Posts: 29
    • View Profile
scripting and ssh commands
« on: September 04, 2019, 07:55:45 pm »

Could realy use some help with scripting, just starting out with it and could use some guidance.

i have peaced together a sample script that is supposed to ssh into device and reboot it, i wanna use it through tool menu. So far i havent got it working yet.

Script: AgentReadList(FindNodeObject($node, 2493), "SSH.Command(192.168.1.10,user,password,put [/system reboot])");

Device never recives any ssh logins
Logged

Victor Kirhenshtein

  • Lead Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 6717
    • View Profile
Re: scripting and ssh commands
« Reply #1 on: September 05, 2019, 01:26:58 pm »

Do you have SSH subagent loaded on node with ID 2493? If yes, check agent's log on that node for how SSH request was processed. You may need to set debug level 5 or higher on agent.

Best regards,
Victor
Logged

Egert143

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: scripting and ssh commands
« Reply #2 on: September 05, 2019, 03:14:20 pm »

Node 2493 is router. i changed it to netxms server and now the script is working.

AgentReadList(FindNodeObject($node, "NetXms-Server"), "SSH.Command(192.168.1.10, username ,password,put [/system reboot])");

When i create tool to run this script, how can i insert dynamic values to script, that are taken from node where tool is used (ip, username, password)?

Egert
« Last Edit: September 05, 2019, 03:54:23 pm by Egert143 »
Logged

Egert143

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: scripting and ssh commands
« Reply #3 on: September 10, 2019, 10:36:44 am »

Any help with last question ? :)
Logged

Victor Kirhenshtein

  • Lead Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 6717
    • View Profile
Re: scripting and ssh commands
« Reply #4 on: September 10, 2019, 12:53:05 pm »

You can use attributes from node objects (NXSL class Node - https://wiki.netxms.org/wiki/NXSL:Node, accessible via $node variable). SSH credentials are not accessible from NXSL, however it version 3.0 we have added method executeSSHCommand in Node class.

Best regards,
Victor
Logged