Virginia Rogers · Apr 20, 2021

What determines the environment for $ZF(-1)?


I'm using $ZF(-1) in a class method which will be invoked from a csp page.

What determines the environment of the spawned process?  If I use $ZF(-1,"echo hello world > output.txt"), the resulting file is owned by cacheusr:cacheusr.  However, when I use $ZF(-1,"printenv > output.txt"), the environment is from my personal unix account, no matter which Cache username I'm logged in under when running the web application.  


Product version: Caché 2017.1
$ZV: Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2017.1
0 197
Discussion (9)0
Log in or sign up to continue


Terminal sessions are run under OS user who runs the terminal.

CSP and Interoperability jobs run under cacheusr or irisusr by default or some other custom user if you specified that during installation.

Thank you Eduard for the quick reply!

However, in my testing, I am not using the terminal, or logged into the OS.  I am calling the $ZF function from a method that is being invoked by a web application.  Is cacheusr somehow tied to a unix username? The cache installation was installed as root, I believe (at least that's who owns the cache binaries and directories).

Yes, agreed.  The thing that puzzles me is that the shell environment variables pertain to my personal account, even though when the $ZF command is invoked from the csp page, and I'm logged into an unrelated cache account.  How is it getting the USER vrogers?

If I use $ZF(-1,"whoami > output.txt"), the output is "cacheusr"

But when I use $ZF(-1,"printenv > output.txt"), the output includes:


Thank you.

Why? Your shell is run under your user (vrogers). You use $ZF(-1) to spawn a child process which inherits everything from parent. Ergo, $ZF(-1) started from shell is also run under your OS user.

Thank you Eduard, I appreciate your time on this.  

Maybe I'm just dense, but I still don't get it.  I'm not logged into the server at all.  I'm only connecting to the server through a CSP application.  In order to access the CSP application, I have to log into one of the cache user accounts.  It doesn't seem to matter which cache account I use -- even if I log in as _SYSTEM to run the CSP application, the $ZF shell is executing under user vrogers.

Hello Virginia, this isn't directly related to your question, but consider using zf(-100) as zf(-1) is deprecated. 2017.1 docs here:


"$ZF(-100) provides similar functionality to $ZF(-1) and $ZF(-2). Its use is preferable to $ZF(-1) or $ZF(-2), which are both deprecated functions."

Thank you for the suggestion, Vic!  I think perhaps it was added after the version I'm using (?). At least, I don't find $ZF(-100) in my documentation and when I try the command, it fails.  Guess we're past due for an update.

Ah, that might be because you are on a base version of 2017.1, but it was added in a maintenance release (perhaps 2017.1.3)? I tried to find some documentation on that but it wasn't super obvious to me. I'd definitely recommend upgrading if possible.