Interrupt running ppp-client connection

I’m trying to disable a ppp-client I use to send some commands through serial port.

I’m able to send commands succesfully with the ppp-client when enabled+disabled manually.
Now I’m trying to script it but I can’t disable interface 1s after enabling it.

add name="Send_code1" policy=ftp,read,write,test,winbox source="/interface ppp-client add \
    add-default-route=no allow=pap,chap,mschap1,mschap2 comment=\"Sends prestored 1\" \\
    dial-command=\"AT\" dial-on-demand=no disabled=yes max-mru=1500 max-mtu=1500 \\
    modem-init=\"commands" mrru=disabled name=\"Code_1\" null-modem=no password=\"\" phone=\"\" \\
    port=serial0 profile=default use-peer-dns=no user=\"\"
/interface ppp-client enable Code_1
:delay 1;
log info \"Command Sent!!!\";
/interface ppp-client disable Code_1;
log info \"IF Disabled!\";
/interface ppp-client remove Code_1;
log info \"IF Removed!\";

I can’t get it working. It gets blocked after “Command Sent!!!”. When I mannually disable the ppp-client, then it logs “IF Disabled!” but it never delets the interface nor log “IF Removed!”.
If my serial device is disconnected, it creates ppp-client, enable it, tries link, then logs “IF Disabled!” and disable interface. But ppp-client is not removed :frowning:

Any ideas?


Many thanks in advance for your great help!!

Hi,

Copy and paste your code in a terminal and read carefully to see where the script bombs. It should give an error just after the line it has a problem with.
If I look quickly, it looks like you telling it to disable/enable/remove an interface that does not exist.

/interface ppp-client disable Code_1;

You named your inteface Send_code1 but you trying to work with an interface with the name Code_1

Your commands should maybe look something like this:

/interface ppp-client enable Send_code_1;
:delay 1;
:log info "Command Sent!!!";
/interface ppp-client disable Send_code_1;
:log info "IF Disabled!";
/interface ppp-client remove Send_code_1;
:log info "IF Removed!";

Hope this helps.

Regards
Leon

/interface pppoe-client disable [ find name="Send_code1" ] ;

That should work.

When writing scripts, you should always use find command.

Hi

You could also ID th ppp interface ina script using

/interface ppp-client enable [find comment="Sends prestored 1"];

Regards
Leon