How to fix exit code: 2 and exit code: 126 in an action or command
Geneos action or command is usually calling a binary or script. If you notice the action or command completes with exit code: 126 as seen below, this means either the gateway or netprobe user (depending which user is executing the command or action) does not have execute permission for the script.
On Linux, users can usually use ls -l command to check file permissions, and use chmod to update the permissions. Please consult your system administrators for help, or search for resources on the internet.
2022-11-10 15:12:28.291-0500 INFO: ActionManager Firing action 'Test Email Alert'
2022-11-10 15:12:29.042-0500 INFO: ActionManager Finished executing '/export/home/mmuniz/geneos-utils-master/system/scripts/email2.pl' with arguments ''.
2022-11-10 15:12:29.076-0500 INFO: ActionManager Completed action 'Test Email Alert', Exit code: 126
If the Geneos action or command completes with exit code: 2 as seen below, this means the script header is incorrect or missing.
2022-11-10 17:29:11.164-0500 INFO: ActionManager Firing action 'Test Email Alert'
2022-11-10 17:29:12.068-0500 INFO: ActionManager Finished executing '/export/home/mmuniz/geneos-utils-master/system/scripts/email2.pl' with arguments ''.
2022-11-10 17:29:12.068-0500 INFO: ActionManager Completed action 'Test Email Alert', Exit code: 2
To fix this, you need to go back to the script and add the header to specify the shell or command interpreter. For example, #!/bin/bash if the script is written in bash.