Jump to content
Калькуляторы

Почему эта команда из терминала выполняется, а как скрипт - нет?

Почему эта команда из терминала выполняется: /system ssh user="ubnt" address="172.16.x.x" command="ifconfig ath0 down"

[admin@MikroTik] > system ssh user="ubnt" address="172.16.250.213" command="ifconfig ath0 up"

Welcome back!

 

,а как скрипт - нет ?

 

[admin@MikroTik] > system script print 
Flags: I - invalid 
0   name="script1" owner="admin" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api 
    last-started=jan/02/1970 07:41:27 run-count=1205 
    source=
      /system ssh user="ubnt" address="172.16.250.213" command="ifconfig ath0 down" 

Счётчик выполнения растёт..

Edited by sergeyfromkomi

Share this post


Link to post
Share on other sites

Потому что микротик не дружит с убнт.

Как-то странно он не дружит... Через терминал микротика, эта же команда отрабатывает как нужно. Может в в кавычках где ошибка?

Share this post


Link to post
Share on other sites

Можно попробовать кавычки вообще убрать для начала=)

 

Поставьте перед ковычками обратный слешь "\"

 

name="script1" owner="admin" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api

last-started=jan/02/1970 07:41:27 run-count=1205

source="/system ssh user=\"ubnt\" address=\"172.16.250.213\" command=\"ifconfig ath0 down\" "

 

http://wiki.mikrotik.com/wiki/Manual:Scripting

Constant Escape Sequences

 

Following escape sequences can be used to define certain special character within string:

\" Insert double quote

\\ Insert backslash

\n Insert newline

\r Insert carriage return

\t Insert horizontal tab

\$ Output $ character. Otherwise $ is used to link variable.

\? Output ? character. Otherwise ? is used to print "help" in console.

\_ - space

\a - BEL (0x07)

\b - backspace (0x08)

\f - form feed (0xFF)

\v Insert vertical tab

\xx Print character from hex value. Hex number should use capital letters.

Edited by Rus123

Share this post


Link to post
Share on other sites

Можно попробовать кавычки вообще убрать для начала=)

 

Поставьте перед ковычками обратный слешь "\"

 

name="script1" owner="admin" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api

last-started=jan/02/1970 07:41:27 run-count=1205

source="/system ssh user=\"ubnt\" address=\"172.16.250.213\" command=\"ifconfig ath0 down\" "

 

http://wiki.mikrotik.com/wiki/Manual:Scripting

 

Не выходит каменный цветок...

Так тоже пробовал:

/system ssh user=ubnt address=172.16.250.213 command=\"ifconfig ath0 down\"

 

Странно, что так запускается:

 
[admin@MikroTik] /system script> print 
Flags: I - invalid 
0   name="my" owner="admin" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api 
    last-started=jan/02/1970 00:51:56 run-count=5 
    source=/system ssh user="ubnt" address="172.16.250.213" command="ifconfig ath0 down"  
[admin@MikroTik] /system script> run 0 

Welcome back!
[admin@MikroTik] /system script>

Edited by sergeyfromkomi

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.