{"id":4575,"date":"2018-01-09T06:21:45","date_gmt":"2018-01-09T06:21:45","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=4575"},"modified":"2021-02-27T09:09:50","modified_gmt":"2021-02-27T09:09:50","slug":"ways-to-pass-password-in-triggers-file-or-script-file-in-perforce","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/","title":{"rendered":"Ways to Pass Password in Triggers file or Script file in Perforce"},"content":{"rendered":"<p><strong>Option 1<\/strong><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><strong>Option 2<\/strong><br \/>\nYou can also use the -P flag to specify the password with the P4 commands issued by the script.<\/p>\n<p><strong>Option 3<\/strong><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.<\/p>\n<p>echo &lt;password&gt;| p4 login<\/p>\n<p><strong>Option 4<\/strong><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.<\/p>\n<p>p4 login &lt; password.txt<\/p>\n<p><strong>Option 5<\/strong><br \/>\nA more secure method is to use ticket based authentication and a group to keep a background user &#8220;logged in&#8221; at the Perforce server:<\/p>\n<p>1. Create a group:<\/p>\n<p>p4 group always_on<\/p>\n<p>2. Add your background user to the &#8220;Users&#8221; field.<\/p>\n<p>3. Change the timeout from the default setting (12 hours), which is set in seconds. The new value depends on the server version:<\/p>\n<p># 2008.1 and later: Set this value to &#8220;unlimited&#8221;. A timeout value of zero is no longer accepted.<\/p>\n<p># 2005.1 to 2007.3: Set this value to zero.<\/p>\n<p># 2004.2 and earlier: Set this to a very large value &#8212; but not too large, as some server versions do not handle situations where the timeout is set to exceed the &#8220;Unix Epoch&#8221;, which is approximately in the year 2038. A safe value is 315532800 seconds, which is about 10 years.<\/p>\n<p># Save the group.<\/p>\n<p># In your trigger script, log the background user in and run the trigger once.<\/p>\n<p>echo password| p4 -p server:port -u username login<\/p>\n<p># If the trigger runs properly, you can remove the password line.<\/p>\n<p>The 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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Option 1 If your Perforce server is set to security level 2 or lower you can have your trigger script [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[22],"tags":[534,373,2941,4492],"class_list":["post-4575","post","type-post","status-publish","format-standard","hentry","category-perforce","tag-password","tag-perforce","tag-perforce-triggers","tag-trigger-script"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Ways to Pass Password in Triggers file or Script file in Perforce - scmGalaxy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ways to Pass Password in Triggers file or Script file in Perforce - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"Option 1 If your Perforce server is set to security level 2 or lower you can have your trigger script [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-09T06:21:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-02-27T09:09:50+00:00\" \/>\n<meta name=\"author\" content=\"scmgalaxy K\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"scmgalaxy K\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\\\/\"},\"author\":{\"name\":\"scmgalaxy K\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\"},\"headline\":\"Ways to Pass Password in Triggers file or Script file in Perforce\",\"datePublished\":\"2018-01-09T06:21:45+00:00\",\"dateModified\":\"2021-02-27T09:09:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\\\/\"},\"wordCount\":343,\"commentCount\":0,\"keywords\":[\"password\",\"Perforce\",\"Perforce Triggers\",\"Trigger script\"],\"articleSection\":[\"Perforce\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\\\/\",\"name\":\"Ways to Pass Password in Triggers file or Script file in Perforce - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"datePublished\":\"2018-01-09T06:21:45+00:00\",\"dateModified\":\"2021-02-27T09:09:50+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ways to Pass Password in Triggers file or Script file in Perforce\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\",\"name\":\"scmgalaxy K\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"caption\":\"scmgalaxy K\"},\"sameAs\":[\"http:\\\/\\\/www.DevOpsSchool.com\"],\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/scmgalaxy\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ways to Pass Password in Triggers file or Script file in Perforce - scmGalaxy","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/","og_locale":"en_US","og_type":"article","og_title":"Ways to Pass Password in Triggers file or Script file in Perforce - scmGalaxy","og_description":"Option 1 If your Perforce server is set to security level 2 or lower you can have your trigger script [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/","og_site_name":"scmGalaxy","article_published_time":"2018-01-09T06:21:45+00:00","article_modified_time":"2021-02-27T09:09:50+00:00","author":"scmgalaxy K","twitter_card":"summary_large_image","twitter_misc":{"Written by":"scmgalaxy K","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/"},"author":{"name":"scmgalaxy K","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102"},"headline":"Ways to Pass Password in Triggers file or Script file in Perforce","datePublished":"2018-01-09T06:21:45+00:00","dateModified":"2021-02-27T09:09:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/"},"wordCount":343,"commentCount":0,"keywords":["password","Perforce","Perforce Triggers","Trigger script"],"articleSection":["Perforce"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/","name":"Ways to Pass Password in Triggers file or Script file in Perforce - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"datePublished":"2018-01-09T06:21:45+00:00","dateModified":"2021-02-27T09:09:50+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/ways-to-pass-password-in-triggers-file-or-script-file-in-perforce\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Ways to Pass Password in Triggers file or Script file in Perforce"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102","name":"scmgalaxy K","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","caption":"scmgalaxy K"},"sameAs":["http:\/\/www.DevOpsSchool.com"],"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/scmgalaxy\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/4575","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=4575"}],"version-history":[{"count":1,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/4575\/revisions"}],"predecessor-version":[{"id":4576,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/4575\/revisions\/4576"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=4575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=4575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=4575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}