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.
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
3. Create %All Namespace:
set $namespace="%SYS",P("Globals")="%DEFAULTDB",sc=##class(Config.Namespaces).Create("%All",.P)
Courtesy of @Eduard Lebedyuk and @Alexey Maslov
4. Enable IRIS BI in a current namespace:
do EnableDeepSee^%SYS.cspServer("/csp/"_$$$LOWER($namespace))
Courtesy of @Benjamin De Boe
Please add your useful lines :) Collaboration is very welcome!
Great idea, thanks Eugene!
But I think it is necessary to collect not so much beautiful one-line useful constructions, but more useful pieces of code, as it was in the projects:
https://github.com/intersystems-community/code-snippets
https://github.com/intersystems-community/objectscript-snippets
https://github.com/eduard93/Utils
Snippets are great and deserve attention, but one-liners have a very certain use case, when you can execute it from the command line or as a docker image tweak
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 ;-)
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.
Bonus: you can New other variables if you want, e.g.
This is really cool, @Alexey Maslov ! Updated two one-liners with your suggestion!
Released a new version with @Alexey Maslov suggestion and two new one-liners, courtesy of @Sylvain Guilbaud
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
Thanks @Ben Spead ! How is this different from:
USER>!<cmd line>
@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 "!":
Again, this is particularly useful when running server-side source control commands (if you need to debug or augment hooks)
A typical use case is WebTerminal !
Good point Robert!
I'm not sure ) This is a command line, yes?
just checked:
.png)
Thanks for the additional use-case :)
and that's the effective code behind
Hey,
here's another one-liner: Change password for preset users
x "new $namespace,s,p,n set $namespace=""%SYS"",p(""Password"")=""NewPass123"" for n=""admin"",""cspsystem"",""iam"",""superuser"",""unknownuser"",""_system"",""_ensemble"" set s=##class(Security.Users).Modify(n,.p)"
@Sergey Mikhailenko - this is great! Could you please send a PR?
"reset" terminal session
This would only kill variables at the current stack level. I think you rather want to do:
Nevertheless a useful tip. Many people don't seem to realize that they need to issue a quit to unwind the stack after an error.
Good point, I guess it depends on the variables scope at that stack level, I generally just run it twice.
Either way, as you say, it is useful to know to do this to ensure "leftovers" don't interfere with later commands.
Added macro for all the one liners.
So you also can
include dc.one.Line
and call
$$$changealladminpass("pass") to change all the predefined passwords to "pass", and other useful one-liners you suggested.
The Line.cls file illustrates the usage.
Suggest your useful one-liners!