Bharath Nunepalli · Apr 3, 2020

Calling Security.Users class in a script


Has anyone tried to call Security.Users class (in %SYS namespace) for creating or editing users from a shell script (or any programming language)?

If yes, can you please share your code?


We are trying to automate some stuff and would like to know how this worked for others.



Bharath Nunepalli.



0 209
Discussion (7)4
Log in or sign up to continue

I've used the Security.Users class in %SYS as well as Security.Roles.  In both cases the documentation suggests you should use the methods to interact with the data.. ie call the Create, Get, Delete methods found in the corresponding class.

I have developed some shell scripts for Caché database maintenance, and they run on AIX.

These scripts just run simple commands like "Status^JOURNAL".

I haven't coded scripts for calling classes or methods. So, just want know whether that's possible in shell scripting or not.

If not, which scripting/programming language should I use for calling classes or methods?

Is there any reason you need to run these scripts from a shell script? That would definitely be possible and there are plenty of examples you can find on the community with a bit of searching, but I think it would be quite simple to do this in Object Script.

You can call methods from command line even like you call routines. Imagine you have a class Test in package TestClasses and a method printData which prints the data to your output device. Then you can call csession instance -"U" namespace "##class(Test).printData("""data""")".

Of course the methods must be ClassMethods. You must test the number of " - signs.  In PowerShell for instance I needed around 14(! sic) "-signs to send a valid command to Caché.

Here the example:

csession ${INSTANCE} -"U" ${NAMESPACE}  "##class(TestClasses.Test).printData(""""""""""""""hello"""""""""""""")"


Hello there Barath,

In order for you to be able to use the name space %SYS in the Secureity.User class I would suggest that you take a closer look into the implementation method and check if you have used or created the methods to interact with data.

An example would be that as follows. Create, Get, Delete methods.

Hope this is useful and helpful. 

Thanks all for your responses.

I'm able to come up with a shell script.

ccontrol list | grep -i running > $DB_STATUS_DET1

if [[ -s $DB_STATUS_DET1 ]] then
 csession cache
 s x=##Class(Security.Users).Create("BOBJ","%ALL","P@ssw0rd!","Bob Jones","","","",0,1,"",1,0,"","","","")
else exit