<?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: su command with expect script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/su-command-with-expect-script/m-p/4287095#M34209</link>
    <description>Yes I thought about the sudo option. But that means I would have to make an entry in the /etc/sudoers file.Since the application I am developing has a constraint that no changes should be made to the file system on the server, I cannot use the sudo option.&lt;BR /&gt;&lt;BR /&gt;Please let me know if you need anymore information on this.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;Rohit Khaladkar</description>
    <pubDate>Thu, 16 Oct 2008 04:08:13 GMT</pubDate>
    <dc:creator>Rohit Khaladkar</dc:creator>
    <dc:date>2008-10-16T04:08:13Z</dc:date>
    <item>
      <title>su command with expect script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/su-command-with-expect-script/m-p/4287093#M34207</link>
      <description>Hi All!&lt;BR /&gt;I need to automate the su command using expect script.Suppose I login as a user A , I need to change the user to oracle using the su oracle command and execute the command "sqlplus -ver".&lt;BR /&gt;&lt;BR /&gt;I tried writing a expect script for the same , but can't figure out the reason it is not working.&lt;BR /&gt;&lt;BR /&gt;Can someone please help. Below is the expect script that I wrote:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/expect -f&lt;BR /&gt;set timeout -1&lt;BR /&gt;spawn /bin/su oracle -c date &lt;BR /&gt;expect "Password: " &lt;BR /&gt;send "oracle\r"&lt;BR /&gt;expect "\r\n"&lt;BR /&gt;send "sqlplus -ver\n"&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Oct 2008 04:43:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/su-command-with-expect-script/m-p/4287093#M34207</guid>
      <dc:creator>Rohit Khaladkar</dc:creator>
      <dc:date>2008-10-15T04:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: su command with expect script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/su-command-with-expect-script/m-p/4287094#M34208</link>
      <description>Probably you don't need expect for this. You only need SUDO. Give SUDO a try.</description>
      <pubDate>Wed, 15 Oct 2008 18:37:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/su-command-with-expect-script/m-p/4287094#M34208</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2008-10-15T18:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: su command with expect script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/su-command-with-expect-script/m-p/4287095#M34209</link>
      <description>Yes I thought about the sudo option. But that means I would have to make an entry in the /etc/sudoers file.Since the application I am developing has a constraint that no changes should be made to the file system on the server, I cannot use the sudo option.&lt;BR /&gt;&lt;BR /&gt;Please let me know if you need anymore information on this.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;Rohit Khaladkar</description>
      <pubDate>Thu, 16 Oct 2008 04:08:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/su-command-with-expect-script/m-p/4287095#M34209</guid>
      <dc:creator>Rohit Khaladkar</dc:creator>
      <dc:date>2008-10-16T04:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: su command with expect script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/su-command-with-expect-script/m-p/4287096#M34210</link>
      <description>The su command in your expect script is "/bin/su oracle -c date", which means only the command "date" is executed as user "oracle". After that, the su session will not accept further commands: the su session will simply end.&lt;BR /&gt;&lt;BR /&gt;You should be doing something like:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/expect -f&lt;BR /&gt;set timeout -1&lt;BR /&gt;spawn /bin/su oracle -c "sqlplus -ver"&lt;BR /&gt;expect "Password: "&lt;BR /&gt;send "oracle\r"&lt;BR /&gt;expect "\r\n"&lt;BR /&gt;# add here suitable expect lines to catch the entire sqlplus -ver output&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Fri, 17 Oct 2008 10:49:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/su-command-with-expect-script/m-p/4287096#M34210</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2008-10-17T10:49:10Z</dc:date>
    </item>
  </channel>
</rss>

