Question
· Jul 30, 2019

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

Discussion (17)0
Log in or sign up to continue

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 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..

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