simulate keypress (force reboot)

Hello,

is it possible to simulate a keypress in a RouterOS script? I’d like to force a reboot in an upgrade script, but

/system reboot

always requires a “y” keypress. I checked the wiki, but didn’t find any solution. I’m new to RouterOS, so bear with me. :wink:

Thanks a lot,
Florian

Are you testing in the terminal? If so, then you’ll have to press Y.

If you schedule the script or run it from WInbox, it won’t ask for confirmation.

Thank you so much - I indeed did test from the terminal. Will have a look at the scripting feature! :wink:
Thanks a lot!

I have a script that tries to reboot when the lte1 interface mysteriously goes away… but the reboot doesn’t work when it is called by the scheduler.

0 name=“check_lte1” owner=“admin” policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon
last-started=mar/03/2017 09:00:00 run-count=553 source=
:global nameInt
:set nameInt “”;

#:log info message=“The WAN interface is $nameInt”;

:do { :set nameInt [/ interface lte get value-name=name number=0;]; } on-error={
/log info message=“Reboot for lte1 recovery”;
/delay 8s;
/system reboot;
/log info message=“Shouldn’t reach here after reboot”;
}


However, when I replace the “/system reboot;” with “/system script run reboot-on-demand;”, where reboot-on-demand is a script that enables a scheduled task that reboots… it works!

Am I doing something wrong??

I wish we had a command line switch to /system reboot that would positively disable the keypress, or another command like /system reboot-without-prompt.

Here is the reboot-on-demand script I mentioned:

2 name=“reboot-on-demand” owner=“admin” policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon
run-count=0 source=/system scheduler enable reboot-on-demand


Here is the scheduler job (initially disabled) that actually can reboot w/o a prompt. When it is enabled, it immediately disables itself to prevent boot loop, then does the “/system reboot” command which works without prompt…

1 X name=“reboot-on-demand” start-date=mar/03/1970 start-time=00:00:00 interval=1s
on-event=/system scheduler disable reboot-on-demand;\n/system reboot; owner=“admin”
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon run-count=0


So again the question; why doesn’t /system reboot work in my other script which is also called by a scheduler job every 5 minutes?