Community discussions

MikroTik App
 
cherdonp
just joined
Topic Author
Posts: 3
Joined: Mon May 02, 2022 5:20 pm

Enable FTP using API

Fri May 06, 2022 1:29 am

Good Day, im pretty new at Perl so forgive me if this is suppose to be simple. Hoping someone here is able to shed some light on how I can enable FTP service in the mikrotik using my perl script. Every syntax Ive tried not working but I know API is logging into the mikrotik fine from my script.

my %attrs = ("/ip/service/enable" , "=ftp");
($retval,@results) = Mtik::mtik_cmd(\%attrs);

Or

($retval,@results) = Mtik::mtik_cmd('/ip/service/enable ftp' , \%attrs);
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7041
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Enable FTP using API

Fri May 06, 2022 9:34 am

You need to get the ID of an entry first. And only then use that ID to enable.
 
cherdonp
just joined
Topic Author
Posts: 3
Joined: Mon May 02, 2022 5:20 pm

Re: Enable FTP using API

Fri May 06, 2022 5:00 pm

Thank you for the speedy reply @mrz. So if Im following you correctly, for example I have a database pulling data for all of the Mtiks, each router has their respective ID number, service number, IP address etc. Are you referring to the ID number from my database attached to that router? Or you are referring to the ID number inside the Mtik ip/service table illustrated below?
# NAME PORT ADDRESS CERTIFICATE
0 XI telnet 23
1 XI ftp 21
2 XI www 80
3 ssh 22
4 XI www-ssl 443 none
5 api 8728
6 winbox 8291
7 api-ssl 8729
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Enable FTP using API

Fri May 06, 2022 5:05 pm

this ID:

terminal code

[admin@MikroTik] > :put  ([/ip service get ftp]->".id")
*1
 
cherdonp
just joined
Topic Author
Posts: 3
Joined: Mon May 02, 2022 5:20 pm

Re: Enable FTP using API

Fri May 06, 2022 8:17 pm

Thank you @rextended. It make sense now.

Who is online

Users browsing this forum: Ahrefs [Bot], JDF and 20 guests