Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List workspaces of a user on a specific machine in Perforce

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
like image 900
elady Avatar asked Oct 20 '22 16:10

elady


2 Answers

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

like image 111
Mark Avatar answered Jan 10 '23 04:01

Mark


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.

like image 32
pitseeker Avatar answered Jan 10 '23 03:01

pitseeker