{"id":1690,"date":"2017-12-05T12:36:43","date_gmt":"2017-12-05T12:36:43","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=1690"},"modified":"2025-02-01T22:39:36","modified_gmt":"2025-02-01T22:39:36","slug":"ways-to-pass-password-in-triggers-file-in-perforce","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/ways-to-pass-password-in-triggers-file-in-perforce\/","title":{"rendered":"Ways to Pass Password in Triggers file in Perforce"},"content":{"rendered":"<p><strong>rajeshkumar created the topic: Ways to Pass Password in Triggers file in Perforce<\/strong><br \/>\nOption 1<br \/>\nIf your Perforce server is set to security level 2 or lower you can have your trigger script run as the same user every time (typically a &#8220;background&#8221; user). Then, either have the server&#8217;s P4PASSWD environment variable set to the background user&#8217;s password,<\/p>\n<p>Option 2<br \/>\nYou can also use the -P flag to specify the password with the P4 commands issued by the script.<\/p>\n<p>Option 3<br \/>\nYou can echo the password and pipe it to the login command. Note that there is no space between the password and the pipe symbol.<br \/>\necho <password>| p4 login<\/p>\n<p>Option 4<br \/>\nIf you do not want to place a password in the script, you can use a text file containing the password. Make sure this password file has appropriate read and write privileges.<br \/>\np4 login < password.txt\n\nOption 5\nA more secure method is to use ticket based authentication and a group to keep a background user \"logged in\" at the Perforce server:\n\n1. Create a group:\np4 group always_on\n\n2. Add your background user to the \"Users\" field.\n\n3. Change the timeout from the default setting (12 hours), which is set in seconds. The new value depends on the server version:\n\n# 2008.1 and later: Set this value to \"unlimited\". A timeout value of zero is no longer accepted.\n\n# 2005.1 to 2007.3: Set this value to zero.\n\n# 2004.2 and earlier: Set this to a very large value -- but not too large, as some server versions do not handle situations where the timeout is set to exceed the \"Unix Epoch\", which is approximately in the year 2038. A safe value is 315532800 seconds, which is about 10 years.\n\n# Save the group.\n\n# In your trigger script, log the background user in and run the trigger once.\necho password| p4 -p server:port -u username login\n\n# If the trigger runs properly, you can remove the password line.\n\nThe user now remains logged in. Since this is ticket based authentication, they remain logged in even if the server is shut down or the hardware is rebooted.\nRegards,\nRajesh Kumar\nTwitt me @ <a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\">twitter.com\/RajeshKumarIn<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>rajeshkumar created the topic: Ways to Pass Password in Triggers file in Perforce Option 1 If your Perforce server is set to security level 2 or lower you can have&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[370],"tags":[373],"class_list":["post-1690","post","type-post","status-publish","format-standard","hentry","category-perforce","tag-perforce"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=1690"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1690\/revisions"}],"predecessor-version":[{"id":1691,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1690\/revisions\/1691"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=1690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=1690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=1690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}