How can I get all Perfoce workspaces of a specific user on a specific machine?
This command let me all workspaces of a specific user on all machines:
P4 clients -u username
How can I get all Perfoce workspaces of a specific user on a specific machine?
This command let me all workspaces of a specific user on all machines:
P4 clients -u username
Here's a cmd one-liner that does more or less the same thing as pitseeker's:
for /f "tokens=2" %x in ('p4 clients -u username') do @(echo %x & p4 client -o %x | findstr /r /c:"^Host:")
A somewhat more robust batch file that seems to fit what you're looking for is:
@echo off
set USER=%1
set HOST=%2
REM Don't forget to double your for-loop percents in batch files,
REM unlike the one-liner above...
for /f "tokens=2" %%x in ('p4 clients -u %USER%') do call :CheckClient %%x
goto :EOF
:CheckClient
p4 client -o %1 | findstr /r /c:"^Host:" | findstr /i /r /c:"%HOST%$">nul && echo %1
goto :EOF
Save that and run it with the username as the first parameter and the desired host name as the second. That is, something like showclient elady elady_pc
Not exactly what you're asking for, but it's easy and perhaps sufficient:
p4 clients -u username | cut -f2 -d' ' | xargs -n 1 p4 client -o |egrep -e '^Client|^Host'
This lists all your clients and their host-restrictions (if any). In the resulting list you can find the specific machines very easily.
The following command returns the host name without an additional time-intensive call to p4 client
for each client, by using a custom output formatter:
p4 clients -ztag -F '%client% %Host%' clients -u username
You can then parse the output using a scripting language of your choice, e.g. Powershell:
p4 clients -ztag -F '%client% %Host%' clients -u username | Select-String " hostname"
(note the space)
To get a list of the available formatting fields that -F can use, run the command with the "-e" or -ztag global options.
© 2022 - 2025 — McMap. All rights reserved.