Welcome to the KM forum!
First, have you read the KM wiki page about executing shell scripts here action:Execute a Shell Script [Keyboard Maestro Wiki] ?
If you have then you’ll know that KM executes scripts in a non-interactive shell whose default path is very different to the one you’ll encounter in Terminal.
Next, there are loads of pitfalls when executing shell scripts in KM which even a cursory search of the forum readily reveals. Consequently it is impossible to say for sure what your problem might be without actually seeing the macro you are having issues with.
It would be worth a few minutes of your time to review these:
- Tip: How Do I Get The Best Answer in the Shortest Time?
- How to Post Your Macro to the Forum.
- Automating Sharing Macros or Actions to the Forum
Since I’m not at my Mac I can’t offer much further assistance, but hopefully you can post your macro and someone else will jump in!