JokerMartini
JokerMartini

Reputation: 6147

perforce root directory path

How can I get the perforce root directory path. I've searched online and I've tried solution such as

p4 -F %clientRoot% -ztag info

However the results returned were empty, but when i run this command:

p4 clients -u jmartini

I get these results:

Client jma_HP001 2017/10/19 root C:\projects\john 'Created by jmartini. '

How can I simply just get the root directory path from command line. I would expect my results to be this:

C:\projects\john

Upvotes: 1

Views: 1911

Answers (1)

Samwise
Samwise

Reputation: 71454

If p4 info doesn't return the current client root, your shell does not have P4CLIENT set correctly. To fix this, you can do:

p4 set P4CLIENT=jma_HP001

From this point on, other commands (including the p4 -F %clientRoot% -ztag info you tried to run first) will return results relative to that client workspace.

If you want to just get the client root out of the clients command you can do:

p4 -F %domainMount% clients -u jmartini

or:

p4 -Ztag -F %Root% clients -u jmartini

Note that if the user owns multiple clients this will get you multiple lines of output.

To figure out the formatting variables you can use with the -F flag, try running commands with the -e or -Ztag global options:

p4 -e clients -u jmartini
p4 -Ztag clients -u jmartini

More on the -F flag in this blog article: https://www.perforce.com/blog/fun-formatting

Upvotes: 3

Related Questions