If you are not using OS single sign-on, this shell script should do it:
csession AUPOLDEVENS <<EOFF
- SuperUser - Is your username
- superuserpassword - Is your SuperUser password
I have chosen SECURITY menu options 1, then option 3. Then I hit ENTER until I exited ^SECURITY routine and terminated the session with the halt command.
If you are using OS single sign-on, remove these two first lines since Caché won't ask for them.
The blank lines after number 3 are the ENTERs you enter to go up into the menu hierarchy until you exit.
The halt is necessary to avoid an error such as the following:
You can do more complex stuff with this technique such as validate errors and return unix error codes to your shell so that you can know if the operation was successful or not:
csession INSTANCENAME <<EOFF
Set tSC = ##class(SomeClass).SomeMethod()
If $System.Status.IsError(tSC) Do $System.Status.DisplayError(tSC) Do $zu(4,$j,1) ;Failure!
Do $zu(4,$j,0) ;OK!
The $zu(4,$j,rc) will halt the session and return the return code on rc to your shell script. As you can notice, the Halt command is not necessary when using this $zu function.
I hope that helps!