Community discussions

MikroTik App
 
johnbuck222
just joined
Topic Author
Posts: 1
Joined: Wed Sep 13, 2023 1:51 pm

Help with script to send message

Wed Sep 13, 2023 1:55 pm

I have the Mikrotik Wireless Wire Cube Pro (https://mikrotik.com/product/wireless_wire_cube_pro) and wanted to make a script which I run on one of the devices which checks whether it can communicate with the other one. Then if it can, it will send it a textual message, say 'hello world'. This will then be displayed in the terminal window of the second device. I tried doing it with a http post request but get a 501 error. Could anyone help? What I have so far is the below:

/system script
add name=send-message source="
:local targetIP 192.168.88.3;
:local messageToSend \"Hello, world!\";

:if ([/ping $targetIP count=1] = 0) do={
:log info \"Target IP ($targetIP) is not reachable.\"
} else={
:log info \"Target IP ($targetIP) is reachable. Sending message...\"
/tool mac-telnet send message=\$messageToSend
}
"

/system scheduler
add name=check-and-send interval=1m on-event="/system script run send-message"
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Help with script to send message

Wed Sep 13, 2023 7:49 pm

What is written makes no sense...

SpamGPT: ###RCHCK###

Ask where you got that sh–ty script, probably from ChatGPT.
Just an idiot would invent the not-actually-existent "send" command from mac-telnet.
ChatGPT (and similar) is just s–t in your face, don't use it.

He made it up just to please you.
ChatGPT is a program for chatting, it must give you satisfaction when you use it, it must get you used to it,
so it will always respond to you with a solution, even an invented one, just to please you.
So basically ChatGPT is a wh–e.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3509
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Help with script to send message

Wed Sep 13, 2023 7:55 pm

My thoughts exactly.

Problem One is ChatGPT is bad at RouterOS script. It does better with stuff like Dockerfile and BIND9, but just makes up too much stuff for RouterOS script.

FWIW, the hallucination is this one:
/tool mac-telnet send message=\$messageToSend
That isn't a valid command is Problem Two.

Problem Three is you can't send a message to the terminal using a script with some different/valid command either. The terminal does have a "chat" by using a "#", but that only works at the CLI terminal - not in scripts. Scripts, include those run by ssh, will treat some chat "# hello world" as a comment.
 
holvoetn
Forum Guru
Forum Guru
Posts: 5500
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: Help with script to send message

Wed Sep 13, 2023 9:33 pm

I am inclined to leave this one (with all accompanying comments) to show as example what rubbish can come from chatGPT (or whatever made it).

Who is online

Users browsing this forum: No registered users and 8 guests