Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script dont work. No mesage in Log #1

Open
SvenPausH opened this issue Jan 20, 2024 · 8 comments
Open

Script dont work. No mesage in Log #1

SvenPausH opened this issue Jan 20, 2024 · 8 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@SvenPausH
Copy link

Hello Philipp, I created the script with the mikrotik json parser.
Unfortunately the script doesn't work.
No message appears in the log and I don't understand why.

@shokinn
Copy link
Owner

shokinn commented Jan 24, 2024

Hi Sven,

  1. Please check if all scripts are created correctly with the correct names (they are case sensitive!).
  2. Check if you set the correct Policies for each script.
  3. Please run the script via the Terminal and check if it prints any errors:
/system/script/run ddns-hetzner
  1. If it does not print any errors
    a. Insert a :log error "[Hetzner DDNS] DEBUG" command starting in the 1st line
    b. Run the script
    c. Check the log can find the log message Hetzner DDNS] DEBUG
    d. If you CAN see the message, move it part, by part down the script and check when you don't get a message anymore.
    e. If you CAN'T see the message, check your logging configuration. Mine is configured as following:
[xxx@xxx] > /system/logging/print 
Flags: * - DEFAULT
Columns: TOPICS, ACTION
#   TOPICS    ACTION
0 * info      memory
1 * error     memory
2 * warning   memory
3 * critical  echo

@SvenPausH
Copy link
Author

Hi, i have 4 Lines whith errors.

Line 134:
:set apiResponse ([/tool/fetch "$apiUrl/zones?page=$apiNextPage&search_name=$configZone" http-method=get http-header-field="Auth-API-Token:$apiKey" output=user as-value]->"data");
Line 162
:local records ([$JSONLoads ([/tool/fetch "$apiUrl/records?zone_id=$zoneId" http-method=get http-header-field="Auth-API-Token:$apiKey" output=user as-value]->"data")]->"records");
Line 171
:set apiResponse ([/tool/fetch "$apiUrl/records/$recordId" http-method=put http-header-field="Content-Type:application/json,Auth-API-Token:$apiKey" http-data=$payload output=user as-value]->"status");
Line 173
:set apiResponse ([/tool/fetch "$apiUrl/records" http-method=post http-header-field="Content-Type:application/json,Auth-API-Token:$apiKey" http-data=$payload output=user as-value]->"status");

If I comment this out then the script runs.
Do you see the error?

@SvenPausH
Copy link
Author

Hi, ok i understand.
:set apiResponse ([/tool/fetch "$apiUrl/zones?page=$apiNextPage&search_name=$configZone" http-method=get http-header-field="Auth-API-Token:$apiKey" output=user as-value]->"data");

There ist a slash to much /tool fetch is better
:set apiResponse ([/tool fetch "$apiUrl/zones?page=$apiNextPage&search_name=$configZone" http-method=get http-header-field="Auth-API-Token:$apiKey" output=user as-value]->"data");

@shokinn
Copy link
Owner

shokinn commented Jan 25, 2024

Hmm /tool fetch and /tool/fetch should work both the same (you can test this also in the terminal).

What I think is that the JParseFunctions are not loaded correctly.

Please try to load the JParseFuctions from your Terminal (so they are available for the whole system)

/system script run "JParseFunctions"; global JSONLoad; global JSONLoads; global JSONUnload

And run the script again afterwards.

If this works for you I would suggest to run the JParseFuctions via the Scheduler on startup.

[xxx@xxx] > /system/scheduler/print                    
Columns: NAME, START-DATE, START-TIME, INTERVAL, ON-EVENT, RUN-COUNT
# NAME             START-DATE  START-TIME  INTERVAL  ON-EVENT         RUN-COUNT
0 xxx                          startup     0s        xxx                      0
1 JParseFunctions              startup     0s        JParseFunctions          0
2 ddns-hetzner     2023-11-10  00:00:00    5m        ddns-hetzner         21810
[xxx@xxx] > /system/scheduler/print detail value-list from=JParseFunctions 
        name: JParseFunctions
  start-time: startup
    interval: 0s
    on-event: JParseFunctions
       owner: xxx
      policy: read,write,test
   run-count: 0

@shokinn shokinn self-assigned this Jan 25, 2024
@SvenPausH
Copy link
Author

Hello,
No, unfortunately it's not what you think.
Which ROS version do you have?
I still have v6. Has anything changed in v7?

[admin@MikroTik4011] > /tool fetch failure: required parameters missing

[admin@MikroTik4011] > /tool/fetch 
expected command name (line 1 column 6)

@shokinn
Copy link
Owner

shokinn commented Jan 25, 2024

I'm on ROS 7, since it was the default for my device (RB5009).
Don't know if anything has changed, but I guess since both options (with slashes or spaces as seperators) are working on v7.
But haven't looked into it detailed, so you have to check it by yourself.
I'm sorry.

When you've fixed it for v6 (and it's also working for v7, without using deprecated options and/or behavior). I'm happy to merge a PR :)

@SvenPausH
Copy link
Author

Hello, in ROS7 both spellings are permitted.
If you adapt your script it will run with ROS6 and ROS7.


  MMM      MMM       KKK                          TTTTTTTTTTT      KKK
  MMMM    MMMM       KKK                          TTTTTTTTTTT      KKK
  MMM MMMM MMM  III  KKK  KKK  RRRRRR     OOOOOO      TTT     III  KKK  KKK
  MMM  MM  MMM  III  KKKKK     RRR  RRR  OOO  OOO     TTT     III  KKKKK
  MMM      MMM  III  KKK KKK   RRRRRR    OOO  OOO     TTT     III  KKK KKK
  MMM      MMM  III  KKK  KKK  RRR  RRR   OOOOOO      TTT     III  KKK  KKK

  MikroTik RouterOS 7.12.1 (c) 1999-2023       https://www.mikrotik.com/

Press F1 for help

[admin@MikroTik] > /tool/fetch 
failure: required parameters missing
[admin@MikroTik] > /tool fetch  
failure: required parameters missing
[admin@MikroTik] >

@shokinn
Copy link
Owner

shokinn commented Jan 26, 2024

Seems like:
https://mikrotik.com/download/changelogs#show-tab-tree_1-id-7cd31cf6820896d838535a73cafb15ca

But they state:

!) new Command Line Interface (CLI) style (RouterOS v6 commands are still supported);

They state, it's still supported, I don't know how long they will carry the old CLI version with them and I don't want to downgrade my script to an "old" cli version.
Also I don't plan to build a v6 compatible version by myself, since 1st I'm not interested in and 2nd I currently don't have to time to do so.

However, as I wrote previously I'm happy to accept a PR with a RouterOS v6 compatible version of the script.

@shokinn shokinn added enhancement New feature or request help wanted Extra attention is needed labels Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants