Hi,
I’m hope having found the right place for my questionin this forum, if not please excuse me…
My goal:
I’m trying to change the hotspot user password via telnet in nodeJS.
My router version:
v6.22.1.
My problem:
In nodeJS I use the telnet-client package from https://github.com/mkozjak/node-telnet-client to connect to my router and then to change the password of a specific hotspot user.
As I can see in the log entries on the router, I get connected but can’t change the password. My command looks like this:
cmd = “/ip hotspot user edit hotspotnamepassword CTRL-K newpassword CTRL-O”;
Question 1: What are CTRL-K and CTRL-O telnet-commands?
Question 2: Is it possible to send the command in one single line or do I have to send “sleep” commands after password (see cmd =…)? The reson why I’m asking Question 2 is that I successfully changed the password via putty and at that step one gets the vi-like editor where one sees the password and can change it via CTRL-K and save it via CTRL-O.
Is there a code example for changing the hotspot user password via telnet?
i tried node.js Api. as example i can view ip address in terminal by running node js code. but i want to run node js script on click html button.
var api = require(‘mikronode’);
var connection = new api(‘192.168.5.1’,‘admin’,‘admin@123’);
connection.connect(function(conn) {
var chan=conn.openChannel();
chan.write('/ip/address/print',function() {
chan.on('done',function(data) {
var parsed = api.parseItems(data);
parsed.forEach(function(item) {
console.log('Interface/IP: '+item.name+"/"+item.address);
});
chan.close();
conn.close();
});
});
Use the “set” command instead. Also, when using the API, be aware of unnamed arguments.
If you’re at a terminal, and type a command, you can then press “?” to see all arguments. Unnamed arguments are written surrounded with “<” and “>”. f.e. most “set” commands have “< numbers >”, meaning that “/ip hotspot set username password=xxx” is the same as “/ip hotspot set numbers=username password=xxx”. You can omit “numbers=” in terminal, but you can’t do that with the API, so: