<?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 Script with different user in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995563#M100697</link>
    <description>I am searching for a script that will run a command under a different user. which means i want the script to do an su - prdadm and then to run the script /usr/.../stopsap and then to exit. how to do this? does it exist, by the way i want to use it for a sap system with data protector.</description>
    <pubDate>Sat, 05 Aug 2006 12:05:11 GMT</pubDate>
    <dc:creator>simon_164</dc:creator>
    <dc:date>2006-08-05T12:05:11Z</dc:date>
    <item>
      <title>Script with different user</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995563#M100697</link>
      <description>I am searching for a script that will run a command under a different user. which means i want the script to do an su - prdadm and then to run the script /usr/.../stopsap and then to exit. how to do this? does it exist, by the way i want to use it for a sap system with data protector.</description>
      <pubDate>Sat, 05 Aug 2006 12:05:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995563#M100697</guid>
      <dc:creator>simon_164</dc:creator>
      <dc:date>2006-08-05T12:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Script with different user</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995564#M100698</link>
      <description>You can install and use SUDO. Once you installed, you can enable users to run commands in behalf other users. For exammple:&lt;BR /&gt;&lt;BR /&gt;# visudo&lt;BR /&gt;&lt;BR /&gt;dpuser   ALL = (prdadm) NOPASSWD: /usr/../stopsap&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Then, dpuser can run:&lt;BR /&gt;&lt;BR /&gt;sudo -u prdadm -H /usr/../stopsap. In this way, the dpuser will run the script as prdadm</description>
      <pubDate>Sat, 05 Aug 2006 12:25:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995564#M100698</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2006-08-05T12:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Script with different user</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995565#M100699</link>
      <description>su - &lt;USER&gt; -c "/path/to/the/script/script&amp;gt;"&lt;/USER&gt;</description>
      <pubDate>Sat, 05 Aug 2006 13:02:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995565#M100699</guid>
      <dc:creator>KapilRaj</dc:creator>
      <dc:date>2006-08-05T13:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Script with different user</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995566#M100700</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;If you are doing it from the root id:&lt;BR /&gt;su - prdadm -c "/usr/.../stopsap &lt;BR /&gt;&lt;BR /&gt;If you want to do it from another id, the you will have to use sudo&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 05 Aug 2006 14:22:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995566#M100700</guid>
      <dc:creator>DCE</dc:creator>
      <dc:date>2006-08-05T14:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Script with different user</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995567#M100701</link>
      <description>This is not what i am looking for, since i want to log in to the user prdadm because of the paths and variables, i tried the &lt;BR /&gt;su - prdadm -c '...' but it always hangs before the user logs in and i need to press enter so that it will enter and do its job.</description>
      <pubDate>Sat, 05 Aug 2006 14:53:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995567#M100701</guid>
      <dc:creator>simon_164</dc:creator>
      <dc:date>2006-08-05T14:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Script with different user</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995568#M100702</link>
      <description>Your problem is the "su - prdadm -c ..." rather than simply "su prdadm -c ...". I know that you want to setup the environemt by sourcing prdadm's .profile but that very .profile has commands like tset, tput, tabs, ... that expect stdin to be a terminal-like device --- which it ain't in this case. There are 2 approaches:&lt;BR /&gt;&lt;BR /&gt;1) Surround all of these commands in .profile with:&lt;BR /&gt;if [ -t 0 ]&lt;BR /&gt;  then&lt;BR /&gt;    tput ..&lt;BR /&gt;    tabs ..&lt;BR /&gt;  fi&lt;BR /&gt;2) better:&lt;BR /&gt;Create a file that sets and exports any needed environment variables e.g. /usr/local/bin/prdadm_env.sh&lt;BR /&gt;and let both your su'ed script AND prdadm's .profile source this file using the "." dot operator.&lt;BR /&gt;&lt;BR /&gt;e.g. . /usr/local/bin/prdadm_env.sh&lt;BR /&gt;&lt;BR /&gt;This sourced file should not contain any exit or return statement because this file becomes part of the foreground process rather than a child process.&lt;BR /&gt;</description>
      <pubDate>Sun, 06 Aug 2006 20:00:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995568#M100702</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-08-06T20:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Script with different user</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995569#M100703</link>
      <description>&amp;gt;I tried the su - prdadm -c '...' but it always hangs before the user logs in and I need to press enter&lt;BR /&gt;&lt;BR /&gt;Can you redirect stdin to /dev/null so it won't bother reading?</description>
      <pubDate>Mon, 07 Aug 2006 16:58:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995569#M100703</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-08-07T16:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Script with different user</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995570#M100704</link>
      <description>The problem was with the user login and i correct it.</description>
      <pubDate>Tue, 08 Aug 2006 04:52:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-with-different-user/m-p/4995570#M100704</guid>
      <dc:creator>simon_164</dc:creator>
      <dc:date>2006-08-08T04:52:07Z</dc:date>
    </item>
  </channel>
</rss>

