<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Help on Script Print Nothing If Error, StdOut if All Good in Splunk Cloud Platform</title>
    <link>https://community.splunk.com/t5/Splunk-Cloud-Platform/Help-on-Script-Print-Nothing-If-Error-StdOut-if-All-Good/m-p/609202#M1704</link>
    <description>&lt;P&gt;Hi Linux Experts!&lt;/P&gt;&lt;P&gt;Need help on a script that I'm working on to log sudo-enabled users. The script that I'm using is below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#!/bin/sh
getent passwd | cut -f1 -d: | xargs -L1 sudo -l -U | grep -v 'not allowed'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is a `.sh` file that's ran once a day. The corresponding output is then parsed and massaged by some SEDCMD stuff, not relevant here.&lt;/P&gt;&lt;P&gt;This way, I can see which users are able to perform sudo on the machine.&amp;nbsp; Note: I am aware of the `usersWithLoginPrivs.sh` but this includes users that I'm not interested.&amp;nbsp; Hence the custom script. If there's another solution you can share, that'd be great. But here's my&lt;/P&gt;&lt;P&gt;PROBLEM: linux admins are complaining that they're getting messaged because `splunk` user that runs this script is generating messages for them. And they don't want to get the messages. So, they suggested to append this command at the end of the script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which I did. However, it does not print output anymore for those Splunk UFs that previously were able to.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, the main solution to this problem is to give `splunk` user permission to run the script. But due to the complexity of our organization, we can't request the same thing across the board.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, basically, of the thousands of linux servers that we have some can run this script, some cannot. That's currently okay.&lt;/P&gt;&lt;P&gt;But to those that cannot, I'd like to modify the script in such a way that it will still work the same but will not produce any error. Is there any alternative?&lt;/P&gt;</description>
    <pubDate>Thu, 11 Aug 2022 18:46:08 GMT</pubDate>
    <dc:creator>morethanyell</dc:creator>
    <dc:date>2022-08-11T18:46:08Z</dc:date>
    <item>
      <title>Help on Script Print Nothing If Error, StdOut if All Good</title>
      <link>https://community.splunk.com/t5/Splunk-Cloud-Platform/Help-on-Script-Print-Nothing-If-Error-StdOut-if-All-Good/m-p/609202#M1704</link>
      <description>&lt;P&gt;Hi Linux Experts!&lt;/P&gt;&lt;P&gt;Need help on a script that I'm working on to log sudo-enabled users. The script that I'm using is below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#!/bin/sh
getent passwd | cut -f1 -d: | xargs -L1 sudo -l -U | grep -v 'not allowed'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is a `.sh` file that's ran once a day. The corresponding output is then parsed and massaged by some SEDCMD stuff, not relevant here.&lt;/P&gt;&lt;P&gt;This way, I can see which users are able to perform sudo on the machine.&amp;nbsp; Note: I am aware of the `usersWithLoginPrivs.sh` but this includes users that I'm not interested.&amp;nbsp; Hence the custom script. If there's another solution you can share, that'd be great. But here's my&lt;/P&gt;&lt;P&gt;PROBLEM: linux admins are complaining that they're getting messaged because `splunk` user that runs this script is generating messages for them. And they don't want to get the messages. So, they suggested to append this command at the end of the script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which I did. However, it does not print output anymore for those Splunk UFs that previously were able to.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, the main solution to this problem is to give `splunk` user permission to run the script. But due to the complexity of our organization, we can't request the same thing across the board.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, basically, of the thousands of linux servers that we have some can run this script, some cannot. That's currently okay.&lt;/P&gt;&lt;P&gt;But to those that cannot, I'd like to modify the script in such a way that it will still work the same but will not produce any error. Is there any alternative?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 18:46:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Cloud-Platform/Help-on-Script-Print-Nothing-If-Error-StdOut-if-All-Good/m-p/609202#M1704</guid>
      <dc:creator>morethanyell</dc:creator>
      <dc:date>2022-08-11T18:46:08Z</dc:date>
    </item>
  </channel>
</rss>

