Scripting for U1900 PBX – Chapter 1 – Adding users

Created 7 days agoLatest reply Dec 07, 2018 23:52:39 42 0 0 0

Scriptingfor U1900 PBX – Chapter 1 – Adding users

 





Description


In scenarios where you need to add SIP users to a U1900 PBX, you can use the web interface to add a group of users in bulk when the numbers are consecutive like 100, 101, 102, etc. But there are cases where there are some non consecutive extension numbers, in these cases you can use the method that will be described in this document. Also, we will add the user name to the extensions in the process. 





Tools needed:


  • Excel (an example file is attached, the example is based on it)  
  • notepad++  
  • LMT (it is strongly recommended to use the corresponding version of the PBX)

***Note: You can use the SSH tool of your choice, but for long scripts LMT works better.

***Note: These guide is based on version V200R003C30, command's syntaxis may change on different versions.



Entering collected information


First we copy or enter the information manually like this:




Cleaning and formating names

Once we have entered information it is important to remove characters in names that won't be recognized by U1900 CLI and cause the script to fail. For this I suggest to use a function like this:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A3,"Ç","C"),"Ú","U"),"Ó","O"),"Ô","O"),"Í","I"),"É","E"),"Ê","E"),"Á","A"),"Ã","A"),"Á","A"),")",""),"(",""),"'","*"),"ó","o"),"ç","c"),"ú","u"),"ô","o"),"í","i"),"é","e"),"ê","e"),"á","a"),"ã","a")," ","*")

For example, this will change something like König to Konig. You can use this and modify to substitute other special characters.

According to documentation, in order to have spaces in the names, we need to enter a * symbol where we need a space. For example to enter Fredric Consolini, we need to enter in our command Fredric*Consolini, in the previous formula, the blank spaces are substituted by a * symbol.

Also you can use the 
TRIM
 function remove preceding and leading characters.









Generating the script

Having the information in our spreadsheet, organized and formatted, now we can enter the next functions



=CONCATENATE("config add sipue eid ",B3," authorizationtype authbyeid password Asdf123!")&CHAR(10)
&CONCATENATE("config add subscriber eid ",B3," dn ",B3," password 123456 webpassword Asdf123!")&CHAR(10)
&CONCATENATE("config modify subscriber dn ",B3," username ",D3)&CHAR(10)
&CONCATENATE((IF(C3="",,CONCATENATE("config modify subscriber dn ",B3," longdn ", C3))))&CHAR(10)




The first line adds a sip user

config add sipue eid 54700 authorizationtype authbyeid password Asdf123!

The second one adds a subscriber 

config add subscriber eid 54700 dn 54700 password 123456 webpassword Asdf123!

The third line adds the name to the subscriber, here we will use the name that has been processed

config modify subscriber dn 54700 username Fredric*Consolini

The 4th line configures the long number, only if thereis a long number. If no long numbervalue is entered, the function will not return any value. 



config modify subscriber dn 54700 longdn 4145799



Notes:

To enter more than one function in excel you need to use the & sign.

"CHAR(10)" in excel equals to pressing enter in your keyboard

It is important to remember that you need to format the cells were you enter your formulas using "Wrap Text"



The functions entered in your cells should look like this:





Copying the generated script

Now we can copy the column E and paste it in notepad++, if you copy the title of the colum (USER CONFIG in this example) make sure you delete it, any line that does not contain any command will result 





As you can see in the next picture, when you paste the copied cells in Notepad++, it also pastes some " signs.






So we need to remove these signs to avoid any error at the moment of running the script. In order to do this you can use the replace function, search for the " sign and replace with a black space.




(OPTIONAL) Also, to reduce lines in your script, you can use a special function in Notepad++ to remove blank lines. Select all your text and delete the blank lines.




This is the final result:




***IMPORTANT NOTE***

At the end of your script always include the command save, if you don't, the changes you make will be lost if the U1900 PBX is restarted.

Save your file.



Running the script


Open LMT, login into the desired PBX and load the script, to do this go to Command Delivery/Script Load:







If everything runs correctly, you will see a screen like this.







Verify the result

To verify the results of your script, you can run the commands show sipue or show subscriber, also you can login the U1900 web interface and go to User menu.


You can find the xls example file in the next link
https://onebox.huawei.com/p/15a359c8ed856716509d9c7fe22e54b4 




This post was last edited by carlosaleman at 2018-12-7 23:59.

This article contains more resources

You need to log in to download or view. No account?Register

x
  • x
  • convention:

Responses

Reply
You need to log in to reply to the post Login | Register

Notice:To ensure the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but not limited to politically sensitive content, content concerning pornography, gambling, drug abuse and trafficking, content that may disclose or infringe upon others' intellectual properties, including commercial secrets, trade marks, copyrights, and patents, and personal privacy. Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see“ Privacy Policy.”
If the attachment button is not available, update the Adobe Flash Player to the latest version!
Fast reply Scroll to top