使用 p4 获取特定计算机上的工作区列表

发布于 2024-09-01 11:11:57 字数 150 浏览 2 评论 0原文

我本来想在 superuser.com 上问这个问题,但那里只有 5 个 perforce 标签,所以我来到这里...... 如何使用 p4 获取特定计算机上的工作区列表?

我可以运行 p4 工作区,但这给了我所有的工作区。 如何将其过滤到特定的计算机(客户端)名称。

I was going to ask this on superuser.com but there were only 5 perforce tags so I came here...
How can I get a list of workspaces on a specific machine with p4?

I can run p4 workspaces, but that gives me all of them, ever.
How can I filter it down to a specific machine(client) name.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

追风人 2024-09-08 11:11:57

取决于您的环境。我已经包含了一个基本的 Windows 批处理文件来执行此操作。

运行 p4 客户端。从每行中取出第二个单词,即客户名称。运行 p4 client -o。 Grep 查找 ^Host:.*\b<主机名>\b。如果 grep 返回成功,则该客户端适用于该机器。积累清单。

在 Windows 中:

set CLIENTS=

for /f "tokens=2" %%c in ('p4 clients') do call :ProcessClient %%c

echo clients on %HOSTNAME% are %CLIENTS%
pause
goto :eof

:ProcessClient
    for /f "tokens=1,2" %%h in ('p4 client -o %1') do if "Host:%HOSTNAME%"=="%%h%%i" set CLIENTS=%CLIENTS% %1
    goto :eof

Depends on your environment. I've included a basic Windows batch file for doing this.

Run p4 clients. Pull the second word out of each line, that's the client name. Run p4 client -o <name>. Grep for ^Host:.*\b<hostname>\b. If grep returns success, that client is for that machine. Accumulate the list.

In Windows:

set CLIENTS=

for /f "tokens=2" %%c in ('p4 clients') do call :ProcessClient %%c

echo clients on %HOSTNAME% are %CLIENTS%
pause
goto :eof

:ProcessClient
    for /f "tokens=1,2" %%h in ('p4 client -o %1') do if "Host:%HOSTNAME%"=="%%h%%i" set CLIENTS=%CLIENTS% %1
    goto :eof
清浅ˋ旧时光 2024-09-08 11:11:57

我知道您指定使用 P4,但您也可以查看 P4Report,它使您可以通过 SQL 查询访问 Perforce。安装后,您只需要一个类似以下的查询:

SELECT clients.client FROM clients WHERE (clients.host='enter your machine here')

您也可以从命令行执行此操作(p4sql -s“查询字符串”)因此,如果您不介意用 P4SQL 代替 P4,您可以比脚本更简洁建议。

P4Report可以在“工具与报告”中找到。 Perforce 下载页面的实用程序部分。

I know you specified using P4, but you could also look at P4Report, which gives you SQL query access to Perforce. Once installed, you would just need a query something like:

SELECT clients.client FROM clients WHERE (clients.host='enter your machine here')

which you can also do from the command line (p4sql -s "query string") So if you don't mind substituting P4SQL for P4 in you can me more concise than the script suggested.

P4Report can be found in the Tools & Utilities section of the Perforce Downloads page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文