Callout

Syndicate content 1 

I have a simple callout library:

#define ZF_DLL
#include 
#include 
#undef ERROR

int GetRandom(double* random) {
   // Py_Initialize();
   // Py_Finalize();
   *random = 1.0;
   return ZF_SUCCESS;
}

int main(int argc, char **argv)
{
   printf("Random: ");
   double random=0;
   GetRandom(&random);
   printf("%lf", random);
   return 0;
}

ZFBEGIN
    ZFENTRY("GetRandom","D",GetRandom)
ZFEND

I compile this code as a shared library and it works fine with:

set path = "library.dll"
write $ZF(-3, path, "GetRandom")

It also compiles and works as an executable.

However, when I uncomment these lines:

   Py_Initialize();
   Py_Finalize();

Shared library compiles, but I get <DYNAMIC LIBRARY LOAD> exception.
Executable version works without errors.

How can I debug this further?

Last answer 16 December 2018 Last comment 16 December 2018
0 2
79

views

0

rating

I am using java gateway imported/proxy classes and JG business service. I need to load a dll at run time.

I use System.loadLibrary/System.load when in java. I’ve tried $ZF(-3,” C:\Windows\System32\pteidlibj.dll”) and $ZF(-4,1,"C:\Windows\System32\pteidlibj.dll") but I’m getting <DYNAMIC LIBRARY LOAD> error.

How can I load a dll at run time using COS?

Last comment 6 May 2016
0 3
582

views

0

rating

There are numerous ways to interact with InterSystems Caché: We can start with ODBC/JDBC that are available via SQL gateway. There are API for .NET and Java too. But if we need to work with native binary libraries, such interaction is  possible through Caché Callout Gateway, which can be tricky. You can read more about the ways of facilitating the work with native libraries directly from Caché in the article below.

Last comment 29 March 2018
0 1
450

views

+ 5

rating

I recently helped a site investigate a problem that appeared after they upgraded their Windows instance of Caché from 2015.1 to 2017.1. A terminal session launched from the server's desktop cube was unable to run OS-level commands using the $ZF(-1) function. For instance, using the no-op command "REM" as follows:

write $zf(-1,"rem")

was returning -1, indicating that the Windows command could not be issued.

It turned out that their original 2015.1 Caché service was running under a specific Windows account (as opposed to LocalSystem), which is commonly done in order to allow background processes to access UNC shares. Indeed, when installing with Normal or Locked Down security you are prompted for the credentials of a Windows account to run the service as

Last comment 27 March 2018
0 4
519

views

+ 7

rating

Hi!

It is often necessary to run some external command such as a python program or a shell script from inside Caché/Ensemble. There are three ways of doing this:

  • $ZF(-1) - Runs the command and waits for it to finish.  
  • $ZF(-2) - Runs the command and don't wait for it to finish.
  • Using CPIPE device - Runs the command and opens a device for you to read its output or (exclusive or here!) write to its input.

$ZF(-1) is normally more interesting because it allows you to recover the return code of the program you are calling. If that is important to you, that is the way to go. But while the program is running, your Caché process will be hung and you won't be able to stop the instance cleanly until it is finished. Normally, for short processes, this is totally acceptable

Last comment 20 February 2018
1 7
1110

views

+ 8

rating

Some time ago I got a WRC case transferred where a customer asks for the availability of a raw DEFLATE compression/decompression function built-in Caché.

When we talk about DEFLATE we need to talk about Zlib as well, since Zlib is the de-facto standard free compression/decompression library developed in the mid-90s.

Zlib works on particular DEFLATE compression/decompression algorithm and the idea of encapsulation within a wrapper (gzip, zlib, etc.).
https://en.wikipedia.org/wiki/Zlib


In Caché Object Script (COS) we already have GZIP support available in using /GZIP=1 on file- or tcp-devices or our Streamclasses for use with gzip files.
http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GOBJ_propstream_gzip

Last comment 31 January 2018
0 3
537

views

+ 7

rating

I use zf(-2) to spawn a external a Java application in a *nix instance.

I would like to kill this process after some conditions met.

I would like to leverage $zf("kill ... ") but this requires its the pid of this child process.

So is there a way to acquire the pid for the child process when I create it ?

If not, how is the suggested way to kill this process?

Thanks.

Last answer 9 January 2018
0 1
0

comments

147

views

0

rating

I could launch a external process via $zf(-2).

However, this child process need to refer some shared libraries in RUNTIME,so I have to set up the proper paths to the environment variable LD_LIBRARY_PATH, is anyone know how to do this?

Thank for your help.

Last answer 26 December 2017 Last comment 9 January 2018
0 1
144

views

0

rating

Is there a way to get one of:

  • Struct
  • $lb
  • Subscripted local variable
  • List/array

As a return type from callout call?

And related question: is there a way to return several values (which may contain commas) from one callout call.  Or rather what's the best approach when doing that?

Last answer 30 November 2017 Last comment 6 December 2017
0 2
166

views

0

rating

Hi I've created a word macro in order to convert doc to txt via the command line, this works fine via the command line by myself or another user but when I try as an the intersystems user which runs under  LocalSystem it doesn't work. 

So can I change the user, or set the $ZF to run as a different user?

Or do I have to try another way to convert doc to txt - it's looking like libreOffice?

I just wanted to stick with word because I could be guaranteed on the result being accurate.

Thanks

Regards

Richard

Last answer 25 April 2017 Last comment 7 November 2017
0 5
390

views

0

rating

Hi guys,

   I am trying to run a command line code using $zf(-1) in cache terminal. it is returning access denied error.

I have tried to run the code in cmd itself it is also throwing Access denied error. But if opened cmd as administrator and run the same code it is working perfectly. I am using windows system. 

Hence i need to know how can i run the cmd line code as administrator using our terminal or studio. Please help me out.

Thanks,

Mani

Last answer 3 November 2017 Last comment 3 November 2017
0 1
415

views

0

rating

Hello everybody,

We have a piece of Caché software which calls an external utility using $zf(-1,command). It works fine under Linux, but under Windows an external process occasionally hangs (due to some internal problems out of the scope here) and need to be killed programmatically. Having PID, it's easy to kill a process. If a Caché process is called with JOB command, the caller can easily get its PID from $zchild, but alas $zf(-1) does not seem to return the similar info. Is it possible to get it somehow?

Last answer 21 August 2017 Last comment 22 August 2017
0 1
282

views

0

rating

Hi everyone,

I have a project which requires the sending of JSON messages to an external service provider using REST. The service provider requires the message contents to be signed.

Their instructions:

  1. Add a header called "Date" with the the date and time in a specific format - done
  2. Add the client's certificate password in a field in the header - done
  3. Create a string which consist of the {Date}{newline}{Password}{newline}{etc}{Message Body}.
    1. Convert to a UTF8 byte array
    2. SHA256 sign the value with the certificate and private key and use RSA PSS padding
    3. Base 64 Encode the value and place it in a Signature field in the header.

I've done the following

Last answer 11 July 2017 Last comment 13 July 2017
0 1
4301

views

0

rating

I have done Python - Cache binding setup following the guide from http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=.... I have also run test.py from sample3 folder and it able to run and complete successfully.

However, when I try to run the same test.py code via $zf, it gives error with exit code 1.

I've tried running help("intersys.pythonbind3") via $zf and also running from Cache terminal as follows:

  1. $zf(-1,"C:\Python36\python <path>/script.py")
  2. ! C:\Python36\python <path>/script.py

which gives me the following output:

problem in intersys.pythonbind3 - ImportError: DLL load failed: The specified module could not be found.

But running the above directly from command prompt is fine

Last answer 11 April 2017 Last comment 6 April 2017
0 0
283

views

0

rating

This is the second part of my long post about package managers in operating systems and language distributions. Now, hopefully, we have managed to convince you that convenient package manager and rich 3rd party code repository is one key factor in establishing of a vibrant and fast growing ecosystem. (Another possible reason for ecosystem success is the consistent language design, but it will be topic for another day.)

In this second part we plan to discuss the practical aspects of creating a package manager in general and their projection to the Caché database environment

Last comment 6 February 2017
0 0
896

views

+ 6

rating

Per the information at http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=... I am trying to use a call to $ZF("GETFILE") to obtain information about an OpenVMS file. But I get an <ILLEGAL VALUE> error.

For example:

w $zf("GETFILE",filename,"UIC")

reports:

<ILLEGAL VALUE>

My filename variable contains the full path and name of a file that I own. I hold the %All role in Cache.

This is 2012.1.5 on OpenVMS/IA64  V8.4

Any ideas what's going wrong?

Last answer 31 January 2017 Last comment 1 February 2017
0 2
138

views

0

rating

Does anyone have a good example of using %Net.SSH.Session  to do a scp copy of a file from one server to another? I tried calling do $ZF(-1,"scp /ensemble/Scott/sr1.dat egate@inteng3:/home/egate/Scott/") but did not have any success in getting the system to copy the file over to what I am calling inteng3.

Thanks

Scott

Last answer 9 December 2016 Last comment 12 December 2016
0 1
336

views

0

rating

Hi,

Thanks for your time.

Plain $ZF(-1) and $ZF(-2) calls from Cache Studio or Terminal have stopped launching the OS shell from Win10.

cmd (Windows Command Prompt) should be launched.

Configuration:

Windows 10 Anniversary Update, Ensemble 2016.2.0.585.0 Developer Edition x64

Is this common? I have enabled both %Developer role and a Cache CallOut privilege for all users that operate in this scenario.

In Terminal, W $ZF(-1) prints -1, W $ZF(-2) prints -1

In Studio, W $ZF(-1) hangs the IDE, W $ZF(-2) prints 0

In all four cases, cmd (Windows Command Prompt) is not launched!

Any ideas, anybody?

Thanks in advance. :-)

Last answer 8 December 2016 Last comment 8 December 2016
0 1
413

views

0

rating

Hello,

we build a COS-application which includes classmethods for running a simulation calculation (differential equations by Runge Kutta procedure) which runs well but needs too much time.  This is embeded in Cache Server Pages and we tried already to start the simulation as a JOB to avoid the CSP-timeout. However the Job needs of course also too much time. May be this could be solved by a different strategy to run the simulation calculation by an external Windows -Programm (developed with Delphi). Original the application for simulation was developed in Delphi, where it needs a significant shorter time than in the COS-application.

Our question is how can we start and execute the windows-programm from a Cache Server Page?

Any hint is welcome?

Lutz.

Last answer 4 August 2016 Last comment 21 September 2016
0 2
763

views

0

rating

Hello Cache experts,

Has anyone tried using Cache object script to check windows service is running or windows service installed or not on same computer or remote computer ? basically i am trying to develop cache program which will check "windows service" running or installed on current computer or remote computer. Based on the status of this windows service, i want to write some business logic in our application. Any suggestions will be more welcome

Last answer 5 August 2016
0 1
0

comments

215

views

0

rating

Introduction

If you manage multiple Caché instances across several servers, you may want to be able to execute arbitrary code from one Caché instance on another. System administrators and technical support specialists may also want to run arbitrary code on remote Caché servers. To address these needs, I have developed a special tool called RCE.

In this article, we will discuss what are the typical ways of solving similar tasks and how RCE (Remote Code Execution) can help.

What possible approaches are available?

Execute OS commands locally

Last comment 25 April 2016
0 3
1834

views

+ 2

rating

When my COS code is executing in a Caché process it might want to interact with the host operating system. For the purpose of this post I'm focusing on a Windows host, but much of it applies to other host OS platforms as well.

A common example of host OS interaction is when my process wants to read from or write to a file. What credentials will apply when Windows is checking whether or not to allow me access to the file?

To answer that we need to consider another question. How did our process start?

If we're in an interactive terminal session, perhaps we launched this from the Caché cube on the server's desktop. In such a case we will already have authenticated to Windows to get onto the server's desktop, so our Caché process can run with those Windows credentials

Last comment 8 March 2016
0 7
429

views

+ 3

rating