Paul,
This type of issue is one we see all too often. I tried to write an Ask-Reuben article about it
https://4js.com/ask-reuben/ig-44/ but I probably tried to say too much in the article.
The issue is you can run something at the command line but you can't from GAS or GST. GAS or GST doesn't do anything magic, deep down it is running a command from a directory within an environment, and so deep down you will find that an environment variable is not what you think it is, or it is because you are in a different directory, or a different process owner with different permissions. It is a case of 1) identifying this difference and 2) making the appropriate change in the GAS/GST config
In your case I'd be looking at environment variable so add the equivalent of a RUN "env | sort > /tmp/filename.env" to your code and run your program from the command line where you say it works and then from GAS where it does't work, and identify any differences in the environment by doing a diff on the result .env files.
With GAS normally the culprit is the database environment varibles INFORMIXDIR, INFORMIXSERVER, LD_LIBRARY_PATH (Unix) / PATH (Windows) etc have not been set appropriately in the .xcf
http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/t_fgl_odiagifx_006.html. They are either blank or are the values that happen to be in the environment when the dispatcher/Studio happens to be launched.
If you don't think FGLPROFILE is being read, then the value of FGLPROFILE will be different or if you are not setting it explicitly FGLDIR might be different. You can also use in your code FGL_GETRESOURCE to see what values are being read from FGLPROFILE
http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_BuiltInFunctions_FGL_GETRESOURCE.html Hope that helps,
Reuben