Community discussions

MikroTik App
 
cicserver
Member
Member
Topic Author
Posts: 303
Joined: Sun Jul 24, 2011 12:04 pm

[SOLVED] Script to export users from PPP to Userman

Mon Feb 24, 2014 7:06 am

I have around 500 users in PPP/Secret section (pppoe users)
I want to migrate these users to User manager (with fix profile of 512kb)

Is there any script which can read from ppp section and then create all users in Userman ??
Last edited by cicserver on Tue Feb 25, 2014 7:48 am, edited 1 time in total.
 
User avatar
skot
Long time Member
Long time Member
Posts: 586
Joined: Wed Nov 30, 2011 3:05 am

Re: Script to export users from PPP to Userman

Tue Feb 25, 2014 2:35 am

This should be possible. You just need to know which PPP items you want to transfer over.

I would test with one user first. The following example transfers user, pass, and ip address. Edit the "ppp1" to be an existing ppp user. Then copy/paste this into the terminal:

ros code

{
:local testName "ppp1"

/ppp secret
:local name [get [find name="testName"] name]
:local pass [get [find name="testName"] password]
:local ip [get [find name="testName"] remote-address]

/tool user-manager user
add name=$name password=$pass ip-address=$ip customer=admin
}
Once you have determined one user will transfer over successfully, then you can automate them all:

ros code

/ppp secret
:foreach i in=[find] do={

:local name [get $i name]
:local pass [get $i password]
:local ip [get $i remote-address]

/tool user-manager user add name=$name password=$pass ip-address=$ip customer=admin
}
I don't need any karma... I have Ιησους Χριστος!
 
cicserver
Member
Member
Topic Author
Posts: 303
Joined: Sun Jul 24, 2011 12:04 pm

Re: Script to export users from PPP to Userman

Tue Feb 25, 2014 7:48 am

thanks mr.scot, problem solved,
 
obadaabdullah
Frequent Visitor
Frequent Visitor
Posts: 71
Joined: Wed Jan 08, 2014 7:41 pm

Re: Script to export users from PPP to Userman

Tue Feb 25, 2014 9:34 pm

This should be possible. You just need to know which PPP items you want to transfer over.

I would test with one user first. The following example transfers user, pass, and ip address. Edit the "ppp1" to be an existing ppp user. Then copy/paste this into the terminal:

ros code

{
:local testName "ppp1"

/ppp secret
:local name [get [find name="testName"] name]
:local pass [get [find name="testName"] password]
:local ip [get [find name="testName"] remote-address]

/tool user-manager user
add name=$name password=$pass ip-address=$ip customer=admin
}
Once you have determined one user will transfer over successfully, then you can automate them all:

ros code

/ppp secret
:foreach i in=[find] do={

:local name [get $i name]
:local pass [get $i password]
:local ip [get $i remote-address]

/tool user-manager user add name=$name password=$pass ip-address=$ip customer=admin
}



Hello mr
i export all of my hotspot users details to a text file (usersd.txt)
my server crash down and i lost all my users data, is there any way to backup them from this file ?
other than writing them manually

thanks
 
User avatar
aacable
Member
Member
Posts: 434
Joined: Wed Sep 17, 2008 11:58 am
Location: ISLAMIC Republic of PAKISTAN
Contact:

Re: [SOLVED] Script to export users from PPP to Userman

Wed Feb 26, 2014 5:54 am

post few lines of your text file here, and maybe , using scripting or simple search and replace in text file, you can restore the users.
_____________
Regard's

Syed Jahanzaib
Web: http://aacable.wordpress.com
Email: aacable [at] hotmail.com
 
techman23
just joined
Posts: 23
Joined: Tue Jun 21, 2016 12:42 am

Re: [SOLVED] Script to export users from PPP to Userman

Sun May 13, 2018 12:53 pm

Hi Skott,

This solution looks great but can you please tell the script through which the hotspot users can be exported to usermanaer



Thanks in advance.

Who is online

Users browsing this forum: No registered users and 8 guests