We are trying to automate the Defender agent on-boarding process from BigFix, we can Install the rpm and shell file, but not able to execute the python file using below comments.
wait /bin/bash python3 /opt/microsoft/mdatp/conf/scripts/MicrosoftDefenderOnboardingLinuxServer.py
While execute the script from linux server then it is working, but from Bigfix action code given error/exit code 126.
Even below shell comment trying to execute from BigFix console and not working .
python3 /opt/microsoft/mdatp/conf/scripts/MicrosoftDefenderOnboardingLinuxServer.py
Thanks,
Nagarajan.
You would likely need to specify the full path to the 'python3' binary. It likely is not part of the $PATH that is being used by the BESClient service (which is running in a non-logon shell so it doesn't source some of the bash dot-files that an interactive logon would load).
Alright, here's my 'general-use' bash script with your command. This should at least provide whatever error output is coming from the shell - the python script itself may have some dependencies that are not met, but in the current form you won't see the error message.
Ok, good to see. Looks like the Python script itself is trying to create the /etc/opt/microsoft/mdatp and failing.
Does the directory already exist? Does it need to be removed before running the script?
When running under 'root', is using 'sudo' valid on this system?
Maybe the script depends on the current working directory. I noticed in your manual steps you have 'cd' into the directory.
I updated my script above to add a 'cd' step in it, please try that version out
I'm afraid there's not much else I could think of, this looks like some problem on your platform or with the python script.
Strange it's expecting to use 'sudo', no script should be silently trying to do 'sudo' since a script can't depend on a user interactively providing a password; in our context, we're already running as root so 'sudo' is not needed, but trying to execute sudo might break things without a running shell.