script to turn off the router

Hi All,
I don know why but I have a problem with very simply script

## Shutdown the cAP
/system ssh address=cAP_IP_ADDRESS user=USER_NAME command="/system shutdown"

## Wait 10s and shoutdown the main router
:delay 10s;
/system shutdown

Why MikroTik might have a problem executing this script??

thanks for your help

If you are trying to run this from scheduler, SSH client will ask for password, and fail, since there is not an interactive terminal on which to ask for the password.

If you run the first command manually on the console, you will see it asks for password, and will not continue until you enter it. It behaves the same way from scheduler, but like mentioned above, is not able to get password, so fails.

Hi, at first thanks for your answer.

I forgot to add one very important thing. I have imported ssh-key and there is no need to type a password.

So, there is no solution??
No ideas, how to solve this issue??

https://wiki.mikrotik.com/wiki/Manual:System/SSH_client#SSH-exec

Also, system shutdown is not required before power off.

http://forum.mikrotik.com/t/help-with-auto-shutdown/110050/1


Mikrotik devices are safe to loose power in normal operation mode. No need to shut down the system before the power outage.

Thank you all for your help
ssh-exec solved my problem.