KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Another approach for issuing shell tasks on MacOS
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac
Published On: March 30, 2018

Another approach for issuing shell tasks on MacOS is to call the shell as the command, and then to feed in the shell tasks as the input parameter to the command, like this:

C_TEXT(vCommand;vInput;vOutput;vErrorText)
vCommand:="/bin/bash"
vInput:="echo -n test | grep test | base64"
LAUNCH EXTERNAL PROCESS(vCommand;vInput;vOutput;vErrorText)

The code snippet above will echo the text 'test' but this output will be piped using the | symbol to the grep command which will grep only the line that includes test which is then piped over to the base64 command before having the output returned to 4D in the vOutput variable.

The output recieved by 4D is "dGVzdAo=\n" which includes a line feed character.

The line feed character can be removed from the output using this code:

vOutput:=Replace String(vOutput;Char(Line Feed);"")

Then, the output in 4D would be "dGVzdAo="