{"id":86,"date":"2008-11-24T11:16:31","date_gmt":"2008-11-24T11:16:31","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2008\/11\/24\/a-script-to-list-the-clients-in-descending-access-date-order\/"},"modified":"2021-02-27T09:56:02","modified_gmt":"2021-02-27T09:56:02","slug":"a-script-to-list-the-clients-in-descending-access-date-order","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/","title":{"rendered":"Script to list the clients in descending access date order"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p align=\"left\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3616 aligncenter\" src=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2008\/11\/script-to-list-the-clients-.png\" alt=\"script-to-list-the-clients-in-descending-access-date-order\" width=\"600\" height=\"400\" srcset=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2008\/11\/script-to-list-the-clients-.png 600w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2008\/11\/script-to-list-the-clients--300x200.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p align=\"left\"><strong>Write a script to list the clients in descending access date order (for deleting obsolete clients).<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #800000;\">#!\/usr\/bin\/ruby<br \/>\nrequire &#8220;P4&#8221;<br \/>\np4 = P4.new<br \/>\np4.tagged<br \/>\np4.connect<br \/>\nclients = p4.run_clients.sort {|a,b| a[ &#8220;Access&#8221;].to_i &lt;=&gt; b[&#8220;Access&#8221;].to_i }<br \/>\nclients[0&#8230;10].each do<br \/>\n|c|<br \/>\nstamp = Time.at( c[ &#8220;Access&#8221; ].to_i )<br \/>\nprintf( &#8220;%-20s %s\\n&#8221;, c[ &#8220;client&#8221; ], stamp )<br \/>\nend<\/span><\/p>\n<p><strong>OR<\/strong><\/p>\n<p><span style=\"color: #800000;\">#!\/usr\/bin\/perl<br \/>\nuse P4;<br \/>\nmy $p4 = new P4;<br \/>\n$p4-&gt;Tag();<br \/>\n$p4-&gt;Init() or die( &#8220;Failed to connect to Perforce&#8221; );<br \/>\nmy @clients = $p4-&gt;Clients();<br \/>\n@clients = sort { $a-&gt;{ &#8220;Access&#8221; } &lt;=&gt; $b-&gt;{ &#8220;Access&#8221; } } @clients;<br \/>\n@clients = @clients[ 0..9 ];<br \/>\nforeach my $client ( @clients )<br \/>\n{<br \/>\nlast unless defined( $client );<br \/>\nmy $stamp = localtime( $client-&gt;{ &#8220;Access&#8221; } );<br \/>\nprintf( &#8220;%-20s %s\\n&#8221;, $client-&gt;{ &#8220;client&#8221; }, $stamp );<br \/>\n}<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Write a script to list the clients in descending access date order (for deleting obsolete clients). &nbsp; #!\/usr\/bin\/ruby require [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":3616,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[57],"tags":[380,903,1905,1910,1904,1911,545,1906,1908,278,1907,1909],"class_list":["post-86","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-access","tag-clients","tag-date","tag-date-order","tag-descending","tag-descending-access-date-order","tag-how","tag-order","tag-order-date","tag-script","tag-script-to-list-the-clients-in-descending-access","tag-sort"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Script to list the clients in descending access date order - 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\/a-script-to-list-the-clients-in-descending-access-date-order\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Script to list the clients in descending access date order - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"&nbsp; Write a script to list the clients in descending access date order (for deleting obsolete clients). &nbsp; #!\/usr\/bin\/ruby require [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2008-11-24T11:16:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-02-27T09:56:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2008\/11\/script-to-list-the-clients-.png\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\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=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/a-script-to-list-the-clients-in-descending-access-date-order\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/a-script-to-list-the-clients-in-descending-access-date-order\\\/\"},\"author\":{\"name\":\"scmgalaxy K\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\"},\"headline\":\"Script to list the clients in descending access date order\",\"datePublished\":\"2008-11-24T11:16:31+00:00\",\"dateModified\":\"2021-02-27T09:56:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/a-script-to-list-the-clients-in-descending-access-date-order\\\/\"},\"wordCount\":144,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/a-script-to-list-the-clients-in-descending-access-date-order\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2008\\\/11\\\/script-to-list-the-clients-.png\",\"keywords\":[\"access\",\"Clients\",\"Date\",\"Date order\",\"Descending\",\"Descending access date order\",\"How\",\"Order\",\"Order date\",\"script\",\"Script to list the clients in descending access\",\"Sort\"],\"articleSection\":[\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/a-script-to-list-the-clients-in-descending-access-date-order\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/a-script-to-list-the-clients-in-descending-access-date-order\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/a-script-to-list-the-clients-in-descending-access-date-order\\\/\",\"name\":\"Script to list the clients in descending access date order - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/a-script-to-list-the-clients-in-descending-access-date-order\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/a-script-to-list-the-clients-in-descending-access-date-order\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2008\\\/11\\\/script-to-list-the-clients-.png\",\"datePublished\":\"2008-11-24T11:16:31+00:00\",\"dateModified\":\"2021-02-27T09:56:02+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/a-script-to-list-the-clients-in-descending-access-date-order\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/a-script-to-list-the-clients-in-descending-access-date-order\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/a-script-to-list-the-clients-in-descending-access-date-order\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2008\\\/11\\\/script-to-list-the-clients-.png\",\"contentUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2008\\\/11\\\/script-to-list-the-clients-.png\",\"width\":600,\"height\":400,\"caption\":\"script-to-list-the-clients-in-descending-access-date-order\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/a-script-to-list-the-clients-in-descending-access-date-order\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Script to list the clients in descending access date order\"}]},{\"@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":"Script to list the clients in descending access date order - 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\/a-script-to-list-the-clients-in-descending-access-date-order\/","og_locale":"en_US","og_type":"article","og_title":"Script to list the clients in descending access date order - scmGalaxy","og_description":"&nbsp; Write a script to list the clients in descending access date order (for deleting obsolete clients). &nbsp; #!\/usr\/bin\/ruby require [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/","og_site_name":"scmGalaxy","article_published_time":"2008-11-24T11:16:31+00:00","article_modified_time":"2021-02-27T09:56:02+00:00","og_image":[{"width":600,"height":400,"url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2008\/11\/script-to-list-the-clients-.png","type":"image\/png"}],"author":"scmgalaxy K","twitter_card":"summary_large_image","twitter_misc":{"Written by":"scmgalaxy K","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/"},"author":{"name":"scmgalaxy K","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102"},"headline":"Script to list the clients in descending access date order","datePublished":"2008-11-24T11:16:31+00:00","dateModified":"2021-02-27T09:56:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/"},"wordCount":144,"commentCount":0,"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2008\/11\/script-to-list-the-clients-.png","keywords":["access","Clients","Date","Date order","Descending","Descending access date order","How","Order","Order date","script","Script to list the clients in descending access","Sort"],"articleSection":["Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/","name":"Script to list the clients in descending access date order - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/#primaryimage"},"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2008\/11\/script-to-list-the-clients-.png","datePublished":"2008-11-24T11:16:31+00:00","dateModified":"2021-02-27T09:56:02+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/#primaryimage","url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2008\/11\/script-to-list-the-clients-.png","contentUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2008\/11\/script-to-list-the-clients-.png","width":600,"height":400,"caption":"script-to-list-the-clients-in-descending-access-date-order"},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/a-script-to-list-the-clients-in-descending-access-date-order\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Script to list the clients in descending access date order"}]},{"@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\/86","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=86"}],"version-history":[{"count":3,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/86\/revisions"}],"predecessor-version":[{"id":3618,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/86\/revisions\/3618"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media\/3616"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}