3

I want to create a trigger for preventing check-out on files if they belong to a specific stream.

I am using the pre-user-edit trigger.

The trigger executes a Perl script.

When I execute in the Perl script a p4 command, then I get this error:

Perforce password (P4PASSWD) invalid or unset.

What I did is getting the stream name out of the client name (which is passed to the Perl script):

 $ stream = `p4 client -o $ client | grep ^Stream: | awk '{print \$ 2}'`;
 chomp $ stream;

This does not work.

Also, trying to assign $p4 with new P4, fails.

Anyone has a clue how to solve this?

At least, give me a way to extract the stream name out the client name?

Thanks,

Xavier T.
  • 40,509
  • 10
  • 68
  • 97
AJ Gottes
  • 401
  • 1
  • 3
  • 15
  • Is your question how to resolve the "password invalid or unset" error? Or is your question how to figure out the stream name to which a particular client workspace is currently set? – Bryan Pendleton Nov 09 '15 at 21:21

3 Answers3

2

You must be logged in to Perforce to run p4 client. In interactive shell you do this by p4 login which prompts you for a password. Once that's validated, Perforce keeps you logged in for a week or so (depends on your P4 server setting). During that week your command should succeed, but once your session expires it will start failing again.

If session expiry is a problem for you, you will need to get hold of a non-expiring ticket. That must be enabled by your server admin (read "To create tickets that do not expire..." att p4 login). See also P4TICKETS.

sferencik
  • 3,144
  • 1
  • 24
  • 36
2

As an alternative,
$ stream = p4 -F "%Stream%" -ztag client -o;

This would just give you the stream name(no trimming is required)

Venkat
  • 31
  • 3
0

As an other alternative, use p4 switch to show the name of the current stream.

Thoma
  • 79
  • 2
  • 4