Article
· Feb 13, 2022 2m read

One Liners - Useful ObjectScript Commands One Line Long

Folks!

Recently I found several one-line long ObjectScript commands on DC and think that it'd be great not to lose it and to collect more!

So I decided to gather a few first cases, put in one OEX project, and share them with you!

And here is how you can use them.

1. Create client SSL configuration.

set $namespace="%SYS", name="DefaultSSL" do:'##class(Security.SSLConfigs).Exists(name) ##class(Security.SSLConfigs).Create(name)

Useful if you need to read content from an URL.

Don't forget to return to a previous namespace. Or add 

n $namespace

before the call. Once you go up in the stack the namespace will be switched to your current namespace automatically.

Source.

2. Install ZPM

set $namespace="%SYS" do ##class(Security.SSLConfigs).Create("ssl") set r=##class(%Net.HttpRequest).%New(),r.Server="pm.community.intersystems.com",r.SSLConfiguration="ssl" do r.Get("/packages/zpm/latest/installer"),$system.OBJ.LoadStream(r.HttpResponse.Data,"c")

Useful, if you don't have ZPM in your IRIS and can install with this one call in the terminal.

Courtesy of @Guillaume Rongier and @Sergei Shutov and @Sergey Mikhailenko 

Source.
 

3. Create %All Namespace:

set $namespace="%SYS",P("Globals")="%DEFAULTDB",sc=##class(Config.Namespaces).Create("%All",.P)

Courtesy of @Eduard Lebedyuk and @Alexey Maslov 

Source

4. Enable IRIS BI in a current namespace:

do EnableDeepSee^%SYS.cspServer("/csp/"_$$$LOWER($namespace))

Courtesy of @Benjamin De Boe

Source.

Please add your useful lines :)  Collaboration is very welcome!

Discussion (22)3
Log in or sign up to continue

Propose No. 5
Create a new database and namespace with resources and mapping in interoperability and install a module from the register into it, for example "dc-one-liners"

At the end of line No. 2 of the zpm installation:

set $namespace="%SYS" do ##class(Security.SSLConfigs).Create("ssl") set r=##class(%Net.HttpRequest).%New(),r.Server="pm.community.intersystems.com",r.SSLConfiguration="ssl" do r.Get("/packages/zpm/latest/installer"),$system.OBJ.LoadStream(r.HttpResponse.Data,"c") zpm "install zapm" zapm "newdb dc-one-liners"

And you can create any number of such one-liners for all possible cases ;-)

Or add 

n $namespace

before the call. Once you go up in the stack the namespace will be switched to your current namespace automatically.

It would not unless you exit the current stack level. To achieve it, you should perform the one-liner as an argument of Xecute command, making it less pleasant, e.g. 

x "new $namespace set $namespace=""%SYS"",P(""Globals"")=""%DEFAULTDB"",sc=##class(Config.Namespaces).Create(""%All"",.P)"

This is great, thank you Evgeny!!  Here is another one that I use, often from the Output window in Studio in order to execute an OS-level command (I most frequently use this for p4 commands to interact with my Perforce server from my IRIS server).  IIRC, original credit goes to @Timothy Leavitt 

Kill stream Set sc = ##class(%Studio.SourceControl.ISC).RunCmd("<insert OS Command here>",.stream,,1) w ! do stream.OutputToDevice() If 'sc {​​​​​ Write $System.Status.GetErrorText(sc) }​​​​​

@Evgeny Shvarov  - you cannot use "!<cmd line>" from the Output window of Studio.  It is often very helpful to run a command from the context of a serverside Caché/InterSystems IRIS process which you can do via the Output Window with the above command, but not with "!":

!whoami
whoami - Error <SYNTAX>

Kill stream Set sc = ##class(%Studio.SourceControl.ISC).RunCmd("whoami",.stream,,1) w ! do stream.OutputToDevice() If 'sc { Write $System.Status.GetErrorText(sc) }
CMD: whoami
irisusr

Again, this is particularly useful when running server-side source control commands (if you need to debug or augment hooks)