Working with $ZF function

Good morning,

I'm trying to understand $ZF function, but only documentation isn't enought in this way. So my question is is there any possibility to get enviroment variable by this function into ensemble?

I've tried this as example from ducumentation, but there is an error and  I don't know why...

Thanks for your solutions.

Zdenek

  • 0
  • 0
  • 186
  • 12
  • 5

Answers

Your sample works for me: 

USER>s rc = $zf(-100,"/SHELL","pwd")
/cachesys/mgr/user

USER>w $zv
Cache for UNIX (Ubuntu Server LTS for x86-64) 2017.2.2 (Build 865U) Mon Jun 25 2018 10:48:26 EDT

What Caché version are you using? $zf(-100) was added in 2017.2.1 (Build 801_3).  For older versions use $zf(-1 or -2), while upgrade to latest Caché (or even IRIS?) release would probably be the better choice.

I've got this version so it should be allright

If i thy $ZF(-1) it's better but still not best.

After cheching my großbuch I found that I was wrong with starting version: $zf(-100) is available since 2017.2.1 (Build 801_3), while your build hasn't got this "_3" suffix.

Zdeněk,

I'm just curious: are you intentionally testing $zf() stuff on command (`pwd`) that doesn't exist in your particular OS?

Yes ok I understand, now I can succesfuly execute script.sh by $ZF(-1) but still I don't know if it's wothit for me, how can I get my variables from script into Cache?

Sorry, didn't mentioned your *new* quesion about environment variables.

I'm confused a bit. Do you keep asking on this issue? If not, please describe your situation in details.

To get environment variable you can use $System.Util.GetEnviron().

And to get current folder -- $system.Process.CurrentDirectory().

I know about GetEnviron() but it's not working, let's see...

It set's me empty string into variable in Cache and I don't know how to fix it. I've got export variable in bash script, but this method doesn't see that. If I use system varieble in windows it's working fine, but I need to use only user/enviroment variables... That's why I'm trying to use $ZF function.. but it doesn't work to..

Seems to work. Please provide small standalone example, so that we can reproduce

C:\InterSystems\ENSEMBLE2017x2x2\bin>set AA=22

C:\InterSystems\ENSEMBLE2017x2x2\bin>echo %AA%
22

C:\InterSystems\ENSEMBLE2017x2x2\bin>cache -s ..\mgr

Узел: ru-akoblovW10VM, Экземпляр: ENSEMBLE2017X2X2

USER>w $system.Util.GetEnviron("AA")
22

Yes ok, this working me too that's not problem, but... I want to set variable in, like in your example, but then I want to run script by this comand

./csession Cache -U "%SYS" <".....\run.script"

But when I started this script it hasn't access to setted variable from cmd. But if I saw your example it gives me some idea, which I need to try.

Zdenek, following up with our offline conversation, I made small change to my installer manifest, so PerformUpgrade() method contains something like this:

    s ^dk="Upgrade to version "_..#VERSION_" performed OK"
    s ^dk("aux")=pAux

    s ^dk("MYVAR")=$System.Util.GetEnviron("MYVAR")
    
    // a nyni muzeme volat kod v manifestu, a nebo taky ne a vse muzeme provest rovnou v teto metode
    set pVars("IsUpgrade")=1
    set pVars("AppVersion")=..#VERSION
    set tSC=..setup(.pVars,3)
    
    return tSC

 

my simple installer script (CentOS7) - that I sent you offline - needs no changes, but before I call it, I do this:

[root@localhost install-scripts]# export MYVAR="kutac"
[root@localhost install-scripts]# echo $MYVAR
kutac
[root@localhost install-scripts]# ./silent-setup.sh 1
about to run only upgrade

then, looking at %SYS namespace what comes into ^dk global:

[root@localhost ~]# csession ens1

Node: localhost.localdomain, Instance: ENS1

Username: root
Password: ********
USER>zn "%sys"

%SYS>zw ^dk
^dk="Upgrade to version 1.2 performed OK"
^dk("MYVAR")="kutac"
^dk("aux")="toto je test"

%SYS>
 

--- as you can see, it works just fine. perhaps your problems are due to security / permissions rather then anything else.

feel free to contact me directly.

 

Dan