Jump to content


Automating Permission changes through command line

protect permission administration cmd command

  • Please log in to reply
3 replies to this topic

#1 RogueDanny

RogueDanny

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 18 May 2017 - 06:53 PM

I've been fiddling around with the
p4 protect
command through Windows' Cmd Prompt. I couldn't come up with a way to update the Permission table in a manner that I could automate later. For instance,
p4 protect -i
does allow standard input to be rerouted to the Permission table, but I don't know of a way to insert that data from, let's say, a text file that has the intended Permission setting.

An example of my intent is:

Current Permissions:
Permissions:
	 super user Me //...
	 write group SomeGroup //...

Permissions to be updated to:
Permissions:
	 super user Me //...
	 open group SomeGroup //...


#2 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1038 posts

Posted 18 May 2017 - 10:27 PM

Do:

p4 protect -i < yourfile.txt

or:


cat yourfile.txt | p4 protect -i

or whatever.

For this to work yourfile.txt must be a valid protections spec (same as what you'd get in the editor when you run "p4 protect" normally) -- usually the easiest way to do this in an automated way is to start with "p4 protect -o", do stuff to the result, and then feed the modified result to "p4 protect -i".

You can also use the --field flags to do simple munging of the spec fields:

p4 --field "Protections=super user Me * //..." --field "Protections+=open group SomeGroup * //..." protect -o | p4 protect -i


#3 RogueDanny

RogueDanny

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 23 May 2017 - 07:39 PM

I shall try it out today, Sambwise. I remember trying:
p4 protect -i < yourfile.txt

Ran into some issue I can't recall. But will try the above steps soon and report back.

Thanks!

#4 RogueDanny

RogueDanny

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 23 May 2017 - 09:00 PM

Tried the first option, it worked. No clue what I was doing that didn't let it execute properly earlier.

Thanks, Sambwise!





Also tagged with one or more of these keywords: protect, permission, administration, cmd, command

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users