<?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 Need help in scripting - in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/need-help-in-scripting/m-p/4766279#M43920</link>
    <description>In Linux, when a normal user enters below command, the OS will prompt for his local password.. This is the interactive way of doing..&lt;BR /&gt;&lt;BR /&gt;$ sudo su -&lt;BR /&gt;Password:&lt;BR /&gt;&lt;BR /&gt;I need advise on how to automate this.. I stored local account password in a file and when I run below command, it still prompts me for password.&lt;BR /&gt;&lt;BR /&gt;$ cat &amp;gt; /tmp/junkfile&lt;BR /&gt;mypassword&lt;BR /&gt;$ sudo su - &amp;lt; /tmp/junkfile&lt;BR /&gt;Password:&lt;BR /&gt;&lt;BR /&gt;How can this be automated.. actually this a part of my scripts which I'm working...&lt;BR /&gt;&lt;BR /&gt;THANK YOU in advance!!&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Girish&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 16 Mar 2011 19:02:50 GMT</pubDate>
    <dc:creator>girish23</dc:creator>
    <dc:date>2011-03-16T19:02:50Z</dc:date>
    <item>
      <title>Need help in scripting -</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-in-scripting/m-p/4766279#M43920</link>
      <description>In Linux, when a normal user enters below command, the OS will prompt for his local password.. This is the interactive way of doing..&lt;BR /&gt;&lt;BR /&gt;$ sudo su -&lt;BR /&gt;Password:&lt;BR /&gt;&lt;BR /&gt;I need advise on how to automate this.. I stored local account password in a file and when I run below command, it still prompts me for password.&lt;BR /&gt;&lt;BR /&gt;$ cat &amp;gt; /tmp/junkfile&lt;BR /&gt;mypassword&lt;BR /&gt;$ sudo su - &amp;lt; /tmp/junkfile&lt;BR /&gt;Password:&lt;BR /&gt;&lt;BR /&gt;How can this be automated.. actually this a part of my scripts which I'm working...&lt;BR /&gt;&lt;BR /&gt;THANK YOU in advance!!&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Girish&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Mar 2011 19:02:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-in-scripting/m-p/4766279#M43920</guid>
      <dc:creator>girish23</dc:creator>
      <dc:date>2011-03-16T19:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in scripting -</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-in-scripting/m-p/4766280#M43921</link>
      <description>Security-sensitive commands like passwd, su and sudo will not obey I/O redirection. This is intentional.&lt;BR /&gt;&lt;BR /&gt;If you want a normal user to be able to do something as root, you should use the "visudo" command to add a line like this to the sudo configuration:&lt;BR /&gt;&lt;BR /&gt;normaluser hostname = (root) NOPASSWD: somecommand&lt;BR /&gt;&lt;BR /&gt;For example: if you want to allow user "girish23" to run /usr/local/bin/rootstuff.sh as root on system "host1", you would add this line to sudo configuration:&lt;BR /&gt;&lt;BR /&gt;girish23 host1 = (root) NOPASSWD: /usr/local/bin/rootstuff.sh&lt;BR /&gt;&lt;BR /&gt;Now, as a normal user girish23, it should be possible to run:&lt;BR /&gt;&lt;BR /&gt;sudo /usr/local/bin/rootstuff.sh&lt;BR /&gt;&lt;BR /&gt;If /usr/local/bin is listed in the PATH environment variable, it is possible to leave out the path:&lt;BR /&gt;&lt;BR /&gt;sudo rootstuff.sh&lt;BR /&gt;&lt;BR /&gt;It's even possible to use I/O redirection and command line arguments:&lt;BR /&gt;&lt;BR /&gt;sudo rootstuff.sh -something somefile &amp;lt; foo &amp;gt; bar&lt;BR /&gt;&lt;BR /&gt;Of course, when you allow normal (non-sysadmin) users to run a script as root, you should make sure the permissions of the script won't allow those users to edit the script: if the script can be modified, you've just given the users a way to do anything they want as root.&lt;BR /&gt;&lt;BR /&gt;----&lt;BR /&gt;&lt;BR /&gt;By the way, when you use "sudo su -", you're using two tools when one would be enough. "sudo -i" will do exactly the same thing, Of course, if your sudo configuration only allows you to run "sudo su -", then that's what you must do... unless you change the sudo configuration to explicitly allow running all commands as root:&lt;BR /&gt;girish23 host1 = (root) ALL&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Wed, 16 Mar 2011 20:00:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-in-scripting/m-p/4766280#M43921</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2011-03-16T20:00:33Z</dc:date>
    </item>
  </channel>
</rss>

