Question
· Jan 11

$ZF question - Calling scripts and redirecting output from script

I am trying to write a ZMIRROR routine that makes a shell script call using $ZF

     Set cmd = "/usr/local/sbin/failover-intengtest-vip"
     Do $ZF(-100,"/ASYNC /SHELL",cmd)

The script I am calling is returning an output to the screen, how do I get around this using $ZF without having to rewrite the scripts?

Thanks

Scott

Product version: IRIS 2022.1
$ZV: IRIS for UNIX (Red Hat Enterprise Linux 8 for x86-64) 2022.1 (Build 209U) Tue May 31 2022 12:13:24 EDT
Discussion (2)3
Log in or sign up to continue

To "capture" output I'd use a pipe instead of $ZF(-100), here a code sample:

Class Community.ExecOS [ Abstract ]
{

/// run an operating system command
ClassMethod ExecOS(cmd As %String, Output LinesOut As %String)
{
    set oldzeof=$SYSTEM.Process.SetZEOF(0)
    set io=$IO,LinesOut=0
    try {
        if cmd="" Quit
        open cmd:"Q" use cmd
        for LinesOut=1:1 {
            read LinesOut(LinesOut)
        }
    } catch CatchError {
        If CatchError.Name'="<ENDOFFILE>" {
            set LinesOut=CatchError.Name
        }
    }
    close cmd
    Do $SYSTEM.Process.SetZEOF(oldzeof)
    Use io
    quit
}

}
EPTEST>d ##class(Community.ExecOS).ExecOS("dir",.out)
 
EPTEST>zw
out=13
out(1)=" Volume in drive C has no label."
out(2)=" Volume Serial Number is 3E11-87B5"
out(3)=""
out(4)=" Directory of c:\intersystems\irishealth\mgr\eptest"
out(5)=""
out(6)="02.01.2024  12:14    <DIR>          ."
out(7)="02.01.2024  12:14    <DIR>          .."
out(8)="11.01.2024  19:04       429'916'160 IRIS.DAT"
out(9)="05.01.2024  14:26                42 iris.lck"
out(10)="24.11.2023  00:34    <DIR>          stream"
out(11)="               2 File(s)    429'916'202 bytes"
out(12)="               3 Dir(s)  63'936'786'432 bytes free"
EPTEST>