Discussion:
TDI 7.2 - system.shellCommand
(too old to reply)
Baptiste Duvey
2020-11-12 10:44:07 UTC
Permalink
Hello all,

I'm trying to run system.shellCommand() with GnuPG library in order to decrypt a file in the prolog of my assembly line.

Command line is pretty simple and perfectly work on shell :
gpg --pinentry-mode loopback --passphrase PASSWORD --output file.csv --decrypt file.pgp

However, when runned using SDI, no error is displayed but the exit value is always 2 which I don't get...
Tried various stuff :
- push the command line directly
- set an array with all my parameters
- put the command in the .bat file

Could you guys give me a hand ?

Thanks in advance,
Baptiste
Eddie Hartman
2020-11-16 11:45:04 UTC
Permalink
Post by Baptiste Duvey
Hello all,
I'm trying to run system.shellCommand() with GnuPG library in order to decrypt a file in the prolog of my assembly line.
gpg --pinentry-mode loopback --passphrase PASSWORD --output file.csv --decrypt file.pgp
However, when runned using SDI, no error is displayed but the exit value is always 2 which I don't get...
- push the command line directly
- set an array with all my parameters
- put the command in the .bat file
Could you guys give me a hand ?
Thanks in advance,
Baptiste
If you have a look in the JavaDocs (under V7.2/docs/api) you will see that system.shellCommand() returns an ExecuteCommand object:

https://www.stephen-swann.co.uk/javadoc/tdi7.1.1/com/ibm/di/function/UserFunctions.html#shellCommand(java.lang.String,%20java.lang.Object)

This ExecuteCommand object provides a number of methods to get the return status of the command. In my experience, it pays to experiment a bit to find out what the command you are invoking returns in way of status. I typically fire up the debugger and then interactively run a series of es = system.shellCommand(...) attempts, each time checking es.failed(), es.getExitValue(), es.getError() and es.getErrorBuffer() to see what works best.

/Eddie

Note: When using commandline arguments I prefer the second variant with arguments passed as an array as the second parameter of the method call.
Baptiste Duvey
2020-11-18 13:12:08 UTC
Permalink
Post by Eddie Hartman
Post by Baptiste Duvey
Hello all,
I'm trying to run system.shellCommand() with GnuPG library in order to decrypt a file in the prolog of my assembly line.
gpg --pinentry-mode loopback --passphrase PASSWORD --output file.csv --decrypt file.pgp
However, when runned using SDI, no error is displayed but the exit value is always 2 which I don't get...
- push the command line directly
- set an array with all my parameters
- put the command in the .bat file
Could you guys give me a hand ?
Thanks in advance,
Baptiste
https://www.stephen-swann.co.uk/javadoc/tdi7.1.1/com/ibm/di/function/UserFunctions.html#shellCommand(java.lang.String,%20java.lang.Object)
This ExecuteCommand object provides a number of methods to get the return status of the command. In my experience, it pays to experiment a bit to find out what the command you are invoking returns in way of status. I typically fire up the debugger and then interactively run a series of es = system.shellCommand(...) attempts, each time checking es.failed(), es.getExitValue(), es.getError() and es.getErrorBuffer() to see what works best.
/Eddie
Note: When using commandline arguments I prefer the second variant with arguments passed as an array as the second parameter of the method call.
Hello Eddie,
Thanks for your answer, didn't used the getErrorBuffer previously as the error was null, thought it wouldn't contain stuff.
It results with a gpg error (no secret key) which is external to SDI, so it's clear for me.

system.shellCommand() is running with administrator account I guess, so I have to precise which keystore is to use.
Thanks for your help :)

Baptiste

Continue reading on narkive:
Loading...