@Eduard Lebedyuk 

1. I have a PDF file which I need to read  from a folder location as text and put data from PDF into HL7 message and send it to downstream system.

2. I have a PDF file which I need to read  from a folder location encode it in base64 and put in OBX.5  of MDM message

@Sergei Shutov 

Classmethod GetJWT() {
//Private key file    
    Set tFile=##Class(%File).%New("C:\keys\jwtRS512.key")
    Do tFile.Close()
    Set tStatus=tFile.Open("RU")
    Set tPrivateKey=tFile.Read()
    Do tFile.Close()
    set iat = ##class(%OAuth2.Utils).TimeInSeconds($ztimestamp,0)
    set exp = ##class(%OAuth2.Utils).TimeInSeconds($ztimestamp,300)

    set tClaims = {
        "sub": "LS6Y4hA6KtDgWwTck5STRdGGVPCPV4Cp",
        "iss": "LS6Y4hA6KtDgWwTck5STRdGGVPCPV4Cp",
        "jti": (tGUID),
        "aud": "https://int.api.service.nhs.uk/oauth2/token",
        "exp": (exp)
    Set JOSE("sigalg")="RS512"
    Set tX509=##class(%SYS.X509Credentials).%New()
    Do tX509.PrivateKeySet(tPrivateKey)
    Set tStatus=##class(%OAuth2.JWKS).AddX509("RS512",tX509,.tPrivate)
    Set arr=##class(%DynamicAbstractObject).%FromJSON(tPrivate)
    Set iter=arr.%GetIterator()
    Set newprivate={}
    ///Need to set KID at same index with other keys so re-creating new 
    While iter.%GetNext(.key,.value) {
            Set newprivate.kty=value.keys.kty
            Set newprivate.n=value.keys.n
            Set newprivate.e=value.keys.e
            Set newprivate.d=value.keys.d
            Set newprivate.p=value.keys.p
            Set newprivate.q=value.keys.q
            Set newprivate.dp=value.keys.dp
            Set newprivate.dq=value.keys.dq
            Set newprivate.qi=value.keys.qi
            Set newprivate.alg=value.keys.alg
            Set newprivate.kid=..KID
    Set JWKSPrivate={"keys":[]}
    Do JWKSPrivate.keys.%Push(newprivate)
    Set tPrivate=JWKSPrivate.%ToJSON()
    ///Customize this method to pass KID that will go to ..GetJWK 3rd argument
    Set tStatus= ##class(KCH.TIE.Helper.PDSUtil).ObjectToJWT(.JOSE,tClaims,tPrivate,,.pJWTToken,..KID)
    W !, pJWTToken

I tried with $ZF(-100) as well still I get code=1 (Syntax error)

same method while running from cache terminal works fine

whereas running from studio gives error

this is local installation

I did tried with complete python.exe path as well. 

but when -ZF(-1) running from studio its not working

I have tried with full path as well still not working 

d $zf(-1,"whoami > c:\temp\whoami.txt")

nt authority\system    ( i dont know which user is this


d $zf(-1,"whoami > c:\temp\whoami.txt")

give local user

Classmethod Test() {

set code $zf(-1,"python C:\keys\GetToken.py")

W ! , code


Classmethod Test2() {

set code $zf(-1,"echo hello>C:\keys\test.txt")

W ! , code


Studio Output Window

Do ##class(Test).Test()


Do ##class(Test).Test2()


Cache terminal

Do ##class(Test).Test()


Do ##class(Test).Test2()



this is what is happening

nope...code =0 means sucess

code =1 means syntax error

I am not sure how same method is behaving differently