Community discussions

MikroTik App
 
dima1002
Member Candidate
Member Candidate
Topic Author
Posts: 157
Joined: Fri Jan 26, 2018 8:40 pm

Read architecture and read file?

Sun Dec 10, 2023 3:33 pm

Hi,

1. How can I display the contents of a file like in Linux with "cat"?
This was my approach so far:
[admin@TESTROUTER] > /log print file=/download/download/LATEST.7
invalid file name

2. How can I read my architecture under Mikrotik?
I've tried this so far:

[admin@TESTROUTER] > /system resource cpu print
Columns: CPU, LOAD, IRQ, DISK
# CPU LOAD IRQ DISK
0 cpu0 0% 0% 0%
1 cpu1 2% 0% 0%
2 cpu2 0% 0% 0%
3 cpu3 0% 0% 0%
[admin@TESTROUTER] > /system resource architecture-name print
bad command name architecture-name (line 1 column 18)
[admin@TESTROUTER] >
 
optio
Long time Member
Long time Member
Posts: 617
Joined: Mon Dec 26, 2022 2:57 pm

Re: Read architecture and read file?

Sun Dec 10, 2023 3:56 pm

1.
:put [/file get "download/download/LATEST.7" contents]
2.
:put [/system/resource get cpu]
 
dima1002
Member Candidate
Member Candidate
Topic Author
Posts: 157
Joined: Fri Jan 26, 2018 8:40 pm

Re: Read architecture and read file?

Sun Dec 10, 2023 4:55 pm

1. Thanks, works perfectly

2. Unfortunately the result looks like this:
[admin@Switch] > :put [/system/resource get cpu]
MIPS 24Kc V8.5
[admin@TESTROUTER] /system> :put [/system/resource get cpu]
ARM64

But I would like to have arm, arm64 or mipbse only there.
 
optio
Long time Member
Long time Member
Posts: 617
Joined: Mon Dec 26, 2022 2:57 pm

Re: Read architecture and read file?

Sun Dec 10, 2023 5:23 pm

You can pick only 1st part before space or whole value if there is no other parts from cpu value:
:local cpu [/system/resource get cpu]
:local spIdx [:find $cpu " "]
:if ($spIdx > 0) do={
  :put [:pick $cpu 0 $spIdx]
} else={
  :put $cpu
}
 
dima1002
Member Candidate
Member Candidate
Topic Author
Posts: 157
Joined: Fri Jan 26, 2018 8:40 pm

Re: Read architecture and read file?

Sun Dec 10, 2023 7:22 pm

I have installed 7.11.2.
When I do that everything stays blank

[admin@Test] > :local cpu [/system/resource get cpu]
[admin@Test] > :local spIdx [:find $cpu " "]
[admin@Test] > :if ($spIdx > 0) do={
{... :put [:pick $cpu 0 $spIdx]
{... } else={
{... :put $cpu
{... }

[admin@Test] >
 
optio
Long time Member
Long time Member
Posts: 617
Joined: Mon Dec 26, 2022 2:57 pm

Re: Read architecture and read file?

Sun Dec 10, 2023 8:02 pm

It must be executed as script, here is single line for CLI if you want like that
:local cpu [/system/resource get cpu]; :local spIdx [:find $cpu " "]; :if ($spIdx > 0) do={ :put [:pick $cpu 0 $spIdx] } else={ :put $cpu }
 
dima1002
Member Candidate
Member Candidate
Topic Author
Posts: 157
Joined: Fri Jan 26, 2018 8:40 pm

Re: Read architecture and read file?

Sun Dec 10, 2023 8:29 pm

I would like to download npk files and would need the exact name for a script: routerros-7.11.2-mipsbe.npk

Unfortunately this is what comes out of the script:
[admin@switch] > :local cpu [/system/resource get cpu]; :local spIdx [:find $cpu " "]; :if ($spIdx > 0) do={ :put [:pick $cpu 0 $spIdx] } else={ :put $cpu }
MIPS
 
optio
Long time Member
Long time Member
Posts: 617
Joined: Mon Dec 26, 2022 2:57 pm

Re: Read architecture and read file?

Sun Dec 10, 2023 8:37 pm

Ah, forget above with cpu parsing, now I see, It's just
:put [/system/resource get architecture-name]
 
dima1002
Member Candidate
Member Candidate
Topic Author
Posts: 157
Joined: Fri Jan 26, 2018 8:40 pm

Re: Read architecture and read file?

Sun Dec 10, 2023 9:59 pm

Thank you very much, that was the solution.

Who is online

Users browsing this forum: diamuxin and 11 guests