Page 1 of 1

Plink script

Posted: Mon Jan 07, 2019 6:40 pm
by RFG
Hello,

I'm using plink as follows:

PLINK.EXE -ssh -P 22 user@host -pw passwd -m MK.ini

When I try to run a script with commands that go into menu level does not recognize. Ex:

/system upgrade
:put [get [find version=6.42.10] status]

If you do in a single line it works. Ex:

/system upgrade;:put [get [find version=6.42.10] status]

Would anyone know the reason?

Re: Plink script

Posted: Mon Jan 07, 2019 10:11 pm
by 2frogs
In your example, “;” is still required at the end of the first line. It stands for “New Line.”

Re: Plink script

Posted: Tue Jan 08, 2019 12:18 am
by maxsaf
:put [system identity get name] works for me

Re: Plink script

Posted: Tue Jan 08, 2019 12:28 am
by Jotne
In your example, “;” is still required at the end of the first line. It stands for “New Line.”
Not true anymore "New Line" works nice. No need for ; anymore.
Only if you like more commands on one line.

https://wiki.mikrotik.com/wiki/Manual:Scripting
The end of command line is represented by the token “;” or NEWLINE. Sometimes “;” or NEWLINE is not required to end the command line.

Re: Plink script

Posted: Tue Jan 08, 2019 12:47 am
by 2frogs
In your example, “;” is still required at the end of the first line. It stands for “New Line.”
Not true anymore "New Line" works nice. No need for ; anymore.
Only if you like more commands on one line.

https://wiki.mikrotik.com/wiki/Manual:Scripting
The end of command line is represented by the token “;” or NEWLINE. Sometimes “;” or NEWLINE is not required to end the command line.
I completely miss read the OP issue! Thought he was trying to issue 2 commands when I responded.

Re: Plink script

Posted: Tue Jan 08, 2019 12:18 pm
by RFG
My intention is to first enter the menu level

/system upgrade

to execute later

:put [get [find version=6.42.10] status]

as it would in a mikrotik script

Re: Plink script

Posted: Tue Jan 08, 2019 1:18 pm
by Jotne
/system upgrade;:put [get [find version = 6.42.10] status]
This does not work for me, it gives red error after = due to the extra space after =.
If I do remove the space, I do get this error:
no such item

What are you trying to do?
Test what version you have?
See if there are newer version?

If you like OS version?
:put [/system resource get version]

Re: Plink script

Posted: Tue Jan 08, 2019 1:51 pm
by RFG
Sorry, the spaces were a copy and paste error. They should not really exist.

If I run direct on the terminal it works, the problem is when I try to do this through plink.

This is part of a mass update script where I need to know if the download has been completed to reboot.