{"id":162,"date":"2023-11-23T00:31:13","date_gmt":"2023-11-23T00:31:13","guid":{"rendered":"http:\/\/10.1.250.135\/ozus\/?page_id=162"},"modified":"2023-11-23T16:06:22","modified_gmt":"2023-11-23T16:06:22","slug":"quick-script-to-pull-extended-shell-history-file-back-to-a-central-server","status":"publish","type":"page","link":"https:\/\/ozus.com\/index.php\/quick-script-to-pull-extended-shell-history-file-back-to-a-central-server\/","title":{"rendered":"Quick Script to pull Extended Shell History file back to a central server"},"content":{"rendered":"\n<p>Create a file called <span style=\"color: blue;\">GetHistoryFiles.ksh. <\/span> Or what ever you would like.<\/p>\n<p><span style=\"color: blue;\">Enter the fillowing into it<\/span><\/p>\n<pre>\t#!\/usr\/bin\/ksh93\n\t# This script is (pwn) by OZUS.LLC and written by Lance Lenz\n\t#\n \n\tfunction qping\n\t{\n\t# Check to see if the node is responding\n\tping -c1 -w1 $1 1&gt;\/dev\/null 2&gt;&amp;1 &amp;&amp; PING=yes || PING=no\n\t}\n\n\t# Read in the Server List\n\tfor nodeName in odcapmdm00 odcapmdm01 odcapmdm03 odcapmdm04 odcaamdm01 odcaamdm02\n\tdo\n\t\t# skip over server names commented out\n\t\t$nodeName == #*  &amp;&amp; continue\n\n\t\t# test to see if the host is managed\n\t\tfor manIt in -man -pers _man\n\t\tdo\n\t\t\tmanNode=$nodeName$manIt\n\t\t\tqping $manNode\n\t\t\tif [ \"$PING\" = \"yes\" ]\n\t\t\tthen\n\t\t\t\tbreak\n\t\t\tfi\n\t\tdone\n\t\tif [ \"$PING\" = \"no\" ] # just try node name\n\t\tthen\n\t\t\tmanNode=$nodeName\n\t\t\tqping $manNode\n\t\tfi\n\n\t\tif [ \"$PING\" = \"yes\" ]\n\t\tthen\n\t\t\techo $nodeName $manNode \n\t\t\t#\n\t\t\tfor i in `ssh root@$manNode ls \/var\/History |awk '{print $1}'`\n\t\t\tdo\n\t\t\t\tinteger CNT=`ssh root@$manNode fuser -f \/var\/History\/${i} 2&gt;&amp;1 | awk '$2 != \"\" { print $1 }'|cut -d: -f1|wc -l`\n\t\t\t\tif [ ${CNT} -eq 0 ];then\n\t\t\t\t\t#echo \"scp root@$manNode:\/var\/History\/${i} \/utlpd02\/History\/Test\/${i}\"\n\t\t\t\t\tscp root@$manNode:\/var\/History\/${i} \/utlpd02\/History\/MDMS\/${i}\n\t\t\t\t\tssh root@$manNode rm \/var\/History\/${i}\n\t\t\t\telse\n\t\t\t\t\techo \"This file is open ${i}\"\n\t\t\t\tfi\n\t\t\tdone\n\t\telse\n\t\t\techo $PING $manNode\n\t\tfi\n\tdone\n\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Create a file called GetHistoryFiles.ksh. Or what ever you would like. Enter the fillowing into it #!\/usr\/bin\/ksh93 # This script is (pwn) by OZUS.LLC and written by Lance Lenz # function qping { # Check to see if the node is responding ping -c1 -w1 $1 1&gt;\/dev\/null 2&gt;&amp;1 &amp;&amp; PING=yes || PING=no } # Read &#8230; <a title=\"Quick Script to pull Extended Shell History file back to a central server\" class=\"read-more\" href=\"https:\/\/ozus.com\/index.php\/quick-script-to-pull-extended-shell-history-file-back-to-a-central-server\/\" aria-label=\"Read more about Quick Script to pull Extended Shell History file back to a central server\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-162","page","type-page","status-publish"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ozus.com\/index.php\/wp-json\/wp\/v2\/pages\/162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ozus.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ozus.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ozus.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ozus.com\/index.php\/wp-json\/wp\/v2\/comments?post=162"}],"version-history":[{"count":1,"href":"https:\/\/ozus.com\/index.php\/wp-json\/wp\/v2\/pages\/162\/revisions"}],"predecessor-version":[{"id":163,"href":"https:\/\/ozus.com\/index.php\/wp-json\/wp\/v2\/pages\/162\/revisions\/163"}],"wp:attachment":[{"href":"https:\/\/ozus.com\/index.php\/wp-json\/wp\/v2\/media?parent=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}