· Mar 13, 2018

Call csession to execute the method and output results

csession can be called with a variety of arguments:

  • tag+offset^routine
  • tag^routine([parameter-list])
  • ##CLASS(package.class).method([parameter-list])

For example I can call:

csession cache "##class(%SYSTEM.OBJ).ShowFlags()"

And that's the output I get because ShowFlags method writes to the current device:

    b - Include sub classes.
    c - Compile. Compile the class definition(s) after loading.
    d - Display. This flag is set by default.
    e - Delete extent.
    h - Generate help.
    i - Validate XML export format against schema on Load.
    k - Keep source.  When this flag is set, source code of
        generated routines will be kept.
    l - Lock classes while compiling.  This flag is set by default.
    p - Percent.  Include classes with names of the form %*.
    r - Recursive.  Compile all the classes that are dependency predecessors.
    s - Process system messages or application messages.
    u - Update only.  Skip compilation of classes that are already up-to-date.
    y - Include classes that are related to the current class in the way that
        they either reference to or are referenced by the current class in SQL usage.

The problem I have is when the method does not write to the current device, but rather returns a value. If I call it nothing is returned:

csession cache "##class(%SYSTEM.Version).GetVersion()"

Is there a way to call these methods and get their result written to the device?

Discussion (4)1
Log in or sign up to continue


   zn "%SYS"
    for e="a","b","c" { w e,! }

use csession with linux PIPE (|) operator: 

cat myScript.scr | csession {instance_name}


cat myScript.scr | csession CACHE

​​​​​Creating a separate file(extension doesn't matter as you are using "cat") when you have got large sequence of commands would be better.


see my full solution