<?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 Re: Multiple Shell Instances for multiple OS commands with filename and pipe option? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Shell-Instances-for-multiple-OS-commands-with-filename/m-p/745151#M233540</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;: sas&amp;nbsp; &amp;nbsp; &amp;nbsp; ALL=(ALL) NOPASSWD:ALL&lt;/P&gt;</description>
    <pubDate>Wed, 02 Jun 2021 12:01:45 GMT</pubDate>
    <dc:creator>FK1</dc:creator>
    <dc:date>2021-06-02T12:01:45Z</dc:date>
    <item>
      <title>Multiple Shell Instances for multiple OS commands with filename and pipe option?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Shell-Instances-for-multiple-OS-commands-with-filename/m-p/745104#M233529</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to execute multiple OS commands out of my EG Session, using the OS root-User. Having found this wonderful&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/Set-amp-SYSRC-from-FILENAME-PIPE/idi-p/579324" target="_blank" rel="noopener"&gt;Filename pipe &lt;/A&gt;&amp;nbsp;approach, I generated this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    %LET l_rm_cmd = %nrbquote(%str(sudo su -; whoami ; rm -f /home/enp2sas/mh.w.jum0080.01 /home/enp2sas/ok.jum0080.01;echo STATUS=$?;));
    %PUT &amp;amp;=l_rm_cmd;
&lt;BR /&gt;    filename oscmd pipe "&amp;amp;l_rm_cmd ";

    %let SYsrc=0;
    %put INFO: &amp;amp;=SYSRC;
    data _null_ ;
       infile oscmd;
       input @;
       put _infile_;
       if _infile_ eq: 'STATUS' then do;
          input status=;
          putlog 'INFO: ' status=;
          call symputx('SYSRC',status);
          end;
       run;
    %put INFO: &amp;amp;=SYSRC;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the corresponding Log:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: The infile OSCMD is:
      Pipe command="sudo su -; whoami ; rm -f /home/enp2sas/mh.w.jum0080.01 /home/enp2sas/ok.jum0080.01;echo STATUS=$?; "

[YOU HAVE NEW MAIL]

sas
rm: 0653-609 Cannot remove /home/enp2sas/mh.w.jum0080.01.
The file access permissions do not allow the specified action.
rm: 0653-609 Cannot remove /home/enp2sas/ok.jum0080.01.
The file access permissions do not allow the specified action.
STATUS=2
INFO: status=2&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the "background" my EG Userprofile is "mapped" to the OS user "sas", therefore, the Log of this code shows me as a result of the OS "whoami" command that the OS commands are executed with the User "sas". I was expecting "root" however, as my first command is "sudo su -".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are these chained commands executed in multiple (KORN) shells, so that the second OS command (i.e. "whoami") is being executed in a different shell, than the "sudo su -" command in front of it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason, why I need to change, is exactly the two error message of the "rm" command, as the "sas" User does not have the neccessary privileges to remove the two files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What confuses me even more is, that the execution of these commands directly in a shell with the User "sas" is working fine, without any errors.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone explain to me what the difference is between executing OS commands from within EG versus directly in a shell?&lt;/P&gt;&lt;P&gt;Why is it not possible to sudo su to root from within a EG session?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 09:17:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Shell-Instances-for-multiple-OS-commands-with-filename/m-p/745104#M233529</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2021-06-02T09:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Shell Instances for multiple OS commands with filename and pipe option?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Shell-Instances-for-multiple-OS-commands-with-filename/m-p/745119#M233535</link>
      <description>&lt;P&gt;Wht does the entry for sas look like in the /etc/sudoers file?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 10:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Shell-Instances-for-multiple-OS-commands-with-filename/m-p/745119#M233535</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-02T10:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Shell Instances for multiple OS commands with filename and pipe option?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Shell-Instances-for-multiple-OS-commands-with-filename/m-p/745151#M233540</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;: sas&amp;nbsp; &amp;nbsp; &amp;nbsp; ALL=(ALL) NOPASSWD:ALL&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 12:01:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Shell-Instances-for-multiple-OS-commands-with-filename/m-p/745151#M233540</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2021-06-02T12:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Shell Instances for multiple OS commands with filename and pipe option?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Shell-Instances-for-multiple-OS-commands-with-filename/m-p/745161#M233546</link>
      <description>&lt;P&gt;I see what happens.&lt;/P&gt;
&lt;PRE&gt;sudo su -&lt;/PRE&gt;
&lt;P&gt;starts a new shell which would wait for input, but since the input stream is not present, it immediately terminates, which also terminates the sudo. After that, the original shell takes over and executes the following commands.&lt;/P&gt;
&lt;P&gt;To do a series of commands as another user, you need to hand those over as a single string like shown here:&amp;nbsp;&lt;A href="https://www.cyberciti.biz/faq/how-to-run-multiple-commands-in-sudo-under-linux-or-unix/" target="_blank" rel="noopener"&gt;https://www.cyberciti.biz/faq/how-to-run-multiple-commands-in-sudo-under-linux-or-unix/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your sudo setup is&amp;nbsp;&lt;STRONG&gt;EXTREMELY DANGEROUS&lt;/STRONG&gt;, and in any safety-conscious organisation this would get you fired. Not just fired&amp;nbsp;&lt;EM&gt;from&lt;/EM&gt;, but fired&amp;nbsp;&lt;EM&gt;at&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;Not only do you effectively make sas a root user, but on top (since this seems to be a shared userid),&amp;nbsp;&lt;EM&gt;anybody&lt;/EM&gt; can do&amp;nbsp;&lt;EM&gt;anything&lt;/EM&gt; to your server.&lt;/P&gt;
&lt;P&gt;Always create a specific script for a specific task, and let the user elevate his permissions for explicitly that script only. Otherwise someone will run&lt;/P&gt;
&lt;PRE&gt;sudo -u root -c "rm -rf /*"&lt;/PRE&gt;
&lt;P&gt;from SAS, and you can kiss your server goodbye. And as a consequence, your professional behind also.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 12:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Shell-Instances-for-multiple-OS-commands-with-filename/m-p/745161#M233546</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-02T12:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Shell Instances for multiple OS commands with filename and pipe option?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Shell-Instances-for-multiple-OS-commands-with-filename/m-p/745197#M233555</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;&lt;P&gt;Kurt, I really like the way you put terrible information into nicely wrapped sentences!&lt;/P&gt;&lt;P&gt;I will inform our server admin of this setup, so he can develop a solution, in order for him not to get his "professional behind" kissed &lt;SPAN&gt;goodbye&lt;/SPAN&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Purely technical speaking, though, it works fine &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thank you for the link!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 14:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Shell-Instances-for-multiple-OS-commands-with-filename/m-p/745197#M233555</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2021-06-02T14:27:56Z</dc:date>
    </item>
  </channel>
</rss>

