Reputation: 997
I want command to check if I am already logged in perforce, which returns 0 if I am logged in, otherwise some non-zero value to represent error. how to achieve this from command line?
Upvotes: 5
Views: 4723
Reputation: 89965
p4 help login
says:
p4 login [-a -p] [-h <host>] [user]
p4 login [-s]
[...]
The -s flag displays the status of the current ticket (if there is one).
Additionally, empirical testing shows that running p4 login -s
while logged in returns an exit code of 0, and running it while not logged in returns an exit code of 1.
Upvotes: 11