Please have a check on the below KB article and see if that helps,
Can you please validate once by running the script from the command line in the agent server with the same user with which you have started the agent services.
I tried running the script from the command line with the same user with which I started the agent services. It ran successfully. Also the script rights are rwx-rwx-rwx. So any user can execute it. The owner of the script is same with which the agent services are installed and started. Any specific steps that I have to do as I am working on Linux?
This seems to be not supported. Feature Request CLDDI-5165 is pending with R&D.
As an alternative, you may call a script in a fixed location which in turns exports the environment variables and call the required scripts.
I don't think that we will able to use the environment variable directly as content in the Script file name parameter of the Command task to define the script file path.
You May select a script file name that was added as an input field, temporary field, or output field in any other step in the taskflow in the command task.
Refer: Command Task step
Let us know if any queries.