CAUTION:
If used incorrectly serious harm can be caused by running scripts left on devices. If a specific script file is not specified,
the Run Local Script action tells Moki Agent to execute any file in the MokiMDM folder that has a .sh extension. It does not remove the files from that location after running, so you just have to push your script once and it will get executed each time the Run Local Scripts action is run. If you have a script that is only meant to be run once, then you should include logic inside of the script to remove the file after it completes.
What is Run Local Scripts used for?
You can use the Run Local Scripts Action to execute any bash script that is located in the MokiMDM folder on the device. This includes being able to run a script to pull device logs.
Using Run Local Scripts for Any Script File:
- Perform a Send File Action to the device, sending the desired bash script file to the device. You must send the file to the MokiMDM file on the device. You can use file path /sdcard/MokiMDM/. Verify that the action has completed under the device Action History.
- Using the Action dropdown, select Run Local Scripts. You have two options:
- You can enter a specific file name located in the MokiMDM folder to run only that specific script file. **Contact Moki Support if you wish to use this feature. This option requires running Agent version 3.9.20 or higher.**
- Use the Pull File List Action to identify the script files already located in the MokiMDM folder on the device
- If no script file is specified, any bash script files located in the MokiMDM folder will be executed. Verify that the action has completed under the device Action History.
- You can enter a specific file name located in the MokiMDM folder to run only that specific script file. **Contact Moki Support if you wish to use this feature. This option requires running Agent version 3.9.20 or higher.**
Using Run Local Scripts to Pull Device Logs Remotely:
- Perform a Send File Action to the device, sending this script file to the device. Use the file path /sdcard/MokiMDM/. Verify that the action has completed under the device Action History.
- Using the Action dropdown, select Run Local Scripts. Verify that the action has completed under the device Action History.
- Perform the Pull File action. Use file path: /sdcard/logcat.txt (if this file path does not work, you can try, /storage/emulated/0/logcat.txt)
- The device log file will be pulled from the device and can be downloaded from the Action History section under the Completed Pull File action
NOTES:
Because the grab logs script file will remain on the device after being pushed once. In the future, if you need to pull device logs on the same device, you do not need to resend the grab log file, and can skip to step 2 above.