Jagadeesha Kris... · Oct 3, 2018

Ccontrol list execution through Cache Object scripting


Anyone worked on "ccontrol  list " command execution through Cache Object Scripting.

I executed through  bat file passing this ../bin ccontrol  list  . Icould not get the results through COS  but executed in command prompt 

it pops up with notepad and list down Cache instances.

Need help here to address the same stuff through cache object scripting.

2 0 3 319
Log in or sign up to continue


You could also use a Command Pipe (docs) and read directly from your OS using "../bin ccontrol  list"  or similar

You just do the usual OPEN + USE and READ whatever comes back.

Able to get the response data with slight changing in the code and added the command in bat file and executed through cache object script. Thank you very much
for your inputs.

You can output the list to a file using this command...

ccontrol list nodisplay > mylist.txt

You could then create a class method to return the contents as a string, something along these lines using $ZF to run the command...

Class Foo.Ccontrol Extends %RegisteredObject

Parameter FOLDER = "C:\InterSystems\Cache2017\bin\";

Parameter FILE = "mylist.txt";

ClassMethod GetList()
  do $ZF(-1,..#FOLDER_"ccontrol list nodisplay > "_..#FILE)
  set stream=##class(%Stream.FileCharacter).%New()
  set sc=stream.LinkToFile(..#FOLDER_..#FILE)
  quit stream.Read()