Community discussions

 
RFG
just joined
Topic Author
Posts: 8
Joined: Wed Dec 13, 2017 4:28 pm

Plink script

Mon Jan 07, 2019 6:40 pm

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?
Last edited by RFG on Tue Jan 08, 2019 1:44 pm, edited 1 time in total.
 
2frogs
Long time Member
Long time Member
Posts: 540
Joined: Fri Dec 03, 2010 1:38 am

Re: Plink script

Mon Jan 07, 2019 10:11 pm

In your example, “;” is still required at the end of the first line. It stands for “New Line.”
 
maxsaf
Frequent Visitor
Frequent Visitor
Posts: 57
Joined: Tue Mar 06, 2018 8:47 pm

Re: Plink script

Tue Jan 08, 2019 12:18 am

:put [system identity get name] works for me
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1310
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: Plink script

Tue Jan 08, 2019 12:28 am

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.
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
2frogs
Long time Member
Long time Member
Posts: 540
Joined: Fri Dec 03, 2010 1:38 am

Re: Plink script

Tue Jan 08, 2019 12:47 am

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.
 
RFG
just joined
Topic Author
Posts: 8
Joined: Wed Dec 13, 2017 4:28 pm

Re: Plink script

Tue Jan 08, 2019 12:18 pm

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
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1310
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: Plink script

Tue Jan 08, 2019 1:18 pm

/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]
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
RFG
just joined
Topic Author
Posts: 8
Joined: Wed Dec 13, 2017 4:28 pm

Re: Plink script

Tue Jan 08, 2019 1:51 pm

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.

Who is online

Users browsing this forum: Google [Bot] and 72 guests