{"id":423,"date":"2017-02-09T16:24:43","date_gmt":"2017-02-09T21:24:43","guid":{"rendered":"http:\/\/www.hpux.ws\/?p=423"},"modified":"2019-11-13T12:25:18","modified_gmt":"2019-11-13T17:25:18","slug":"a-script-to-identify-entries-for-a-particular-user","status":"publish","type":"post","link":"http:\/\/www.hpux.ws\/?p=423","title":{"rendered":"A Script to identify entries for a particular user"},"content":{"rendered":"<p>Starting a series on automation scripting.<\/p>\n<p>This one is meant to be run from a master of the universe host, eg a host with root public keys placed on all work servers.<\/p>\n<p>cat searchforid.ksh<\/p>\n<p>\u00a0<\/p>\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/ksh\n#\n# test script\n#\n. .\/.scriptenv\n# provides standardization for example SSH_CMD=\"ssh -q -f -o ConnectionAttempts=3 -o ConnectTimeout=10 -o PasswordAuthentication=no -o BatchMode=yes\"\n\nLF=\"${LOGDIR}\/${0}.logfile.txt\"\n> ${LF}\nsc=0\n\nuid=$1\ndate >> ${LF}\n\nawk '{ print $1 }' $serverlist | while read -r hn\ndo\necho \"################### ${hn} searching for user ${uid} ######################\"\necho \"################### ${hn} searching for user ${uid} ######################\" >> ${LF}\nif [ \"${hn}\" != \"mygush0\" ]\nthen\n  ${SSH_CMD} ${hn} \"grep ${uid} \/opt\/iexpress\/sudo\/etc\/sudoers;grep ${uid} \/etc\/passwd\"\n  sleep 5\n  ${SSH_CMD} ${hn} \"grep ${uid} \/opt\/iexpress\/sudo\/etc\/sudoers;grep ${uid} \/etc\/passwd\" >> ${LF}\n\nelse\n  grep ${uid} \/opt\/iexpress\/sudo\/etc\/sudoers;grep ${uid} \/etc\/passwd\n  grep ${uid} \/opt\/iexpress\/sudo\/etc\/sudoers >> ${LF};grep ${uid} \n  \/etc\/passwd >> ${LF}\n  echo  \n \n \"#######################################################################################################\"\necho \"#######################################################################################################\" >> ${LF}\n\nfi\ndone\necho \"Success count: ${sc} \" >> ${LF}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Starting a series on automation scripting. This one is meant to be run from a master of the universe host, eg a host with root public keys placed on all work servers. cat searchforid.ksh \u00a0<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_kadence_starter_templates_imported_post":false,"footnotes":""},"categories":[39,8],"tags":[154,153,152],"class_list":["post-423","post","type-post","status-publish","format-standard","hentry","category-scripting","category-sysadmin","tag-automation-script","tag-hp-ux-script","tag-user-search-script"],"_links":{"self":[{"href":"http:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/posts\/423"}],"collection":[{"href":"http:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=423"}],"version-history":[{"count":6,"href":"http:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/posts\/423\/revisions"}],"predecessor-version":[{"id":626,"href":"http:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/posts\/423\/revisions\/626"}],"wp:attachment":[{"href":"http:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=423"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}