There is a post in the Cobol Forum regarding executing Unix commands from within a Cobol program using CALL "SYSTEM"..... When I try to do the same thing from a program running on a Linux-server the program ends with return code 512
77 ws-command pic x(40) value 'ls -l > lsout.txt'.
77 ws-rc-out pic s9(9) comp.
call 'system' using ws-command returning ws-rc-out.
display 'RC=' ws-rc-out
The file lsout.txt is created but it is empty.
The return code is +000000512
I have tried executing windows-commands when I run program in eclipse and that works well.
Am I barking up the wrong tree or is this possible to achieve?
First use "SYSTEM" rather than "system", as this will ensure it works with screen handling.
Next the API needs to be zero terminated... for example:
77 ws-command pic x(40) value z"ls -l > lsout.txt".
I would also use:
77 ws-command pic x(80) value z'/bin/bash -c "ls -l >lsout.txt"'.