screenshot_macos.sh - limehawk/rmm-scripts GitHub Wiki
screenshot_macos.sh
Captures a timestamped screenshot on macOS using the native screencapture utility.
Overview
This script provides automated screenshot capture for macOS systems, saving images with timestamped filenames to a consistent location. Designed for RMM platform integration to enable remote visual troubleshooting.
Purpose
Enables remote screenshot capture for troubleshooting and monitoring purposes without user interaction. Uses the native macOS screencapture utility for silent operation without notification sounds.
Prerequisites
- Operating System: macOS 10.12 or later
- Utilities: screencapture (standard macOS component)
- Privileges: No special privileges required (runs as user)
Configuration
Required Inputs
All settings are hardcoded in the script:
- Save Directory:
/tmp/screenshots/ - Filename Format:
screenshot_YYYYMMDD_HHMMSS.png - Image Format: PNG
- Capture Mode: Silent (no sound)
No parameters required - all settings are embedded in the script.
Behavior
- Directory Creation:
- Checks if
/tmp/screenshots/exists - Creates directory if needed using
mkdir -p
- Checks if
- Timestamp Generation:
- Creates timestamp in format
YYYYMMDD_HHMMSS - Example:
20250601_143022
- Creates timestamp in format
- Screenshot Capture:
- Uses
screencapture -xfor silent capture - Captures entire screen
- Saves to
/tmp/screenshots/screenshot_[timestamp].png
- Uses
- Verification:
- Reports success and full file path
- Returns exit code 0 on success
The script exits immediately on any error due to set -euo pipefail.
Security Notes
- No special privileges required
- Saves to
/tmp/directory (cleared on reboot) - No network access or data transmission
- Screenshot contains visible screen content at time of capture
- Files stored unencrypted in temporary directory
- RMM platform should retrieve and delete screenshots promptly
Exit Codes
- 0: Screenshot captured successfully
- 1: Screenshot capture failed:
- screencapture utility failed
- Unable to create save directory
- Disk full or write error
Example Output
[ SCREENSHOT CAPTURE - macOS ]
--------------------------------------------------------------
Creating screenshot directory...
Capturing screenshot...
[ FINAL STATUS ]
--------------------------------------------------------------
Result : SUCCESS
Saved to : /tmp/screenshots/screenshot_20250601_143022.png
[ SCRIPT COMPLETED ]
--------------------------------------------------------------
Version History
- v1.0.0: Initial release
- Silent screenshot capture
- Timestamped filenames
- RMM-compatible output location
- Automatic directory creation
Links
- View Script Source
- Scripts - Back to script index