#!/usr/bin/env bash
#
# client_report.sh - Generate a CSV report of Perforce client workspaces for maintenance review.
usage() {
cat <<EOF
Usage: $(basename "$0") [-h] [OUTPUT_FILE]
Generate a CSV report of all Perforce client workspaces, including last access date,
owner, and ready-to-run commands for unloading, reloading, or deleting each client.
Useful for identifying stale workspaces and performing bulk cleanup operations.
Arguments:
OUTPUT_FILE Path for the output CSV file (default: client_report.csv)
Options:
-h Show this help message and exit
Examples:
$(basename "$0")
$(basename "$0") /tmp/p4_clients_$(date +%Y%m%d).csv
Requirements:
- p4 CLI must be in PATH and authenticated
- 'date' must support the -d flag (GNU coreutils)
EOF
}
# --- Argument parsing ---
while getopts ":h" opt; do
case $opt in
h) usage; exit 0 ;;
\?) echo "Unknown option: -$OPTARG" >&2; usage >&2; exit 1 ;;
esac
done
shift $((OPTIND - 1))
OUTPUT="${1:-client_report.csv}"
# --- Main ---
echo "Client, Last Access, Owner, Command to unload client, Command to reload client, Command to remove client" > "$OUTPUT"
p4 -ztag -F "%client%|%Access%|%Owner%" clients | while IFS='|' read -r client access owner; do
if [[ -z "$access" || "$access" == "0" ]]; then
formatted="N/A"
else
formatted=$(date -d "@$access" +"%m/%d/%Y")
fi
echo "$client, $formatted, $owner, p4 unload -c $client, p4 reload -c $client, p4 client -d $client"
done >> "$OUTPUT"
echo "Report written to: $OUTPUT"
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #1 | 33433 | Claude (AI Agent by Anthropic) |
Copy Up from //p4-sdp/dev into //p4-sdp/main. This is the first-ever population of main under the new Streams-based depot structure -- main has held zero files/history until now, since no release has ever gone through this process before. 463 files, covering the entire 2026.1 cycle: rebranding (SDP-1379), Secure By Default (SDP-1350), OrgName-aware auth.id/ServerID (SDP-1286), RCS-keyword version identification (SDP-1161/SDP-799), the Streams-native release process redesign itself (Task 5), the opt_perforce_sdp_backup.sh false-error fix, the P4D 2026.1 test-suite targeting, refreshed P4*.json files, and the fixed-main-URL/isolate-downloads tarball design -- everything accumulated in dev's history to date. Isolated paths (ai_dev_support/, Version, doc/*.html, doc/*.pdf, doc/gen/*.man.txt, doc/gen/sdp_install.cfg, Unsupported/doc/*.html, Unsupported/doc/*.pdf, downloads/) correctly did not come along -- each stream maintains those independently by design. Per the Merge Down/Copy Up flow (Step 9 confirmed clean, nothing to merge), this is an unconditional, all-or-nothing copy of dev's content -- this is the first Streams-based SDP release, being rehearsed step by step per the release process doc. Agent: Claude Code, Model: Claude Sonnet 5 (claude-sonnet-5), operating as bot_Claude_Anthropic. |
||
| //p4-sdp/dev/Unsupported/Maintenance/client_report.sh | |||||
| #1 | 32726 | C. Thomas Tyler |
p4 merge -b SDP_Classic_to_Streams p4 resolve -as # Only trival resolve was needed. |
||
| //guest/perforce_software/sdp/dev/Unsupported/Maintenance/client_report.sh | |||||
| #1 | 32711 | Mark Zinthefer |
Adding reporting scripts client_report.sh and label_report.sh. Each generates a spreadsheet of all worskapces or labels with last access date, owner, delete, unload, and reload commands. Client, Last Access, Owner, Command to unload client, Command to reload client, Command to remove client workspace_1, 05/29/2026, mark, p4 unload -c workspace_1, p4 reload -c workspace_1, p4 client -d workspace_1 workspace_10, 05/29/2026, mark, p4 unload -c workspace_10, p4 reload -c workspace_10, p4 client -d workspace_10 workspace_2, 05/29/2026, mark, p4 unload -c workspace_2, p4 reload -c workspace_2, p4 client -d workspace_2 Label, Last Access, Owner, Command to unload label, Command to reload label, Command to remove label label_1, 05/29/2026, mark, p4 unload -l label_1, p4 reload -l label_1, p4 label -d label_1 label_10, 05/29/2026, mark, p4 unload -l label_10, p4 reload -l label_10, p4 label -d label_10 label_11, 05/29/2026, mark, p4 unload -l label_11, p4 reload -l label_11, p4 label -d label_11 label_12, 05/29/2026, mark, p4 unload -l label_12, p4 reload -l label_12, p4 label -d label_12 label_13, 05/29/2026, mark, p4 unload -l label_13, p4 reload -l label_13, p4 label -d label_13 label_14, 05/29/2026, mark, p4 unload -l label_14, p4 reload -l label_14, p4 label -d label_14 |
||