<?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>question Re: How to automate ambari LDAP sync through expect script in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-automate-ambari-LDAP-sync-through-expect-script/m-p/172370#M50193</link>
    <description>&lt;P&gt;Regarding your query: &lt;EM&gt;"is there any alternative how the script can get executed automatically from crontab?"\&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt; crontab -e&lt;/PRE&gt;&lt;P&gt;
 Then add the following entry in the crontab:&lt;/P&gt;&lt;PRE&gt; 0 15 *  *  *  /PATH/TO/ambari_ldap_sync_all.sh&lt;/PRE&gt;&lt;P&gt;
 However above approach has nothing to do with HDP or Ambari. It's simple Linux.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Dec 2016 15:56:22 GMT</pubDate>
    <dc:creator>jsensharma</dc:creator>
    <dc:date>2016-12-27T15:56:22Z</dc:date>
    <item>
      <title>How to automate ambari LDAP sync through expect script</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-automate-ambari-LDAP-sync-through-expect-script/m-p/172366#M50189</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I have used ambari-ldap sync script but I get the following 
error when I ran the below command. One thing I noticed is that if the 
run the script manually as ./ambari_ldap_sync_all.sh then its getting 
executed.&lt;/P&gt;&lt;P&gt;Also I have shown my ambari-ldap sync script below. So the script is 
not getting executed from crontab with 'sh' command . &lt;/P&gt;&lt;PRE&gt;[root@host1(172.23.34.4)] # sh ambari_ldap_sync_all.sh
ambari_ldap_sync_all.sh: line 3: spawn: command not found
couldn't read file "Enter Ambari Admin login:": no such file or directory
ambari_ldap_sync_all.sh: line 7: send: command not found
couldn't read file "Enter Ambari Admin password:": no such file or directory
ambari_ldap_sync_all.sh: line 11: send: command not found
couldn't read file "eof": no such file or directory

[root@host1(172.23.34.4)] # cat ambari_ldap_sync_all.sh
#!/usr/bin/expect

spawn ambari-server sync-ldap --existing 

expect "Enter Ambari Admin login:"

send "admin\r"

expect "Enter Ambari Admin password:"

send "admin\r"

expect eof

[root@host1(172.23.34.4)] # crontab -e
00 15 * * * /ambari_ldap_sync_all.sh
&lt;/PRE&gt;&lt;P&gt;Can someone help me how to write expect script if it is required??&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 15:22:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-automate-ambari-LDAP-sync-through-expect-script/m-p/172366#M50189</guid>
      <dc:creator>rburagohain</dc:creator>
      <dc:date>2016-12-27T15:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to automate ambari LDAP sync through expect script</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-automate-ambari-LDAP-sync-through-expect-script/m-p/172367#M50190</link>
      <description>&lt;P&gt;@&lt;A href="https://community.hortonworks.com/users/3578/rburagohain.html"&gt;Rahul Buragohain&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Have you done &lt;/P&gt;&lt;PRE&gt;# yum install expect -y &lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 15:30:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-automate-ambari-LDAP-sync-through-expect-script/m-p/172367#M50190</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2016-12-27T15:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to automate ambari LDAP sync through expect script</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-automate-ambari-LDAP-sync-through-expect-script/m-p/172368#M50191</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3418/jsensharma.html" nodeid="3418"&gt;@Jay SenSharma&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Yes expect package is already installed. Actually my issue is the script is not getting executed at 3pm even though it is configured in crontab. As I said, when I ran the command manually as ./ambari_ldap_sync_all.sh then it works. So is there any alternative how the script can get executed automatically from crontab?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 15:41:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-automate-ambari-LDAP-sync-through-expect-script/m-p/172368#M50191</guid>
      <dc:creator>rburagohain</dc:creator>
      <dc:date>2016-12-27T15:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to automate ambari LDAP sync through expect script</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-automate-ambari-LDAP-sync-through-expect-script/m-p/172369#M50192</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3578/rburagohain.html" nodeid="3578"&gt;@Rahul Buragohain&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The error that you posted clearly indicates that the packages are not properly installed (OR) the current users PATH does is not correct.  (OR) after installing the "expect" package you have not included the "#!/usr/bin/expect"  at the beginning of your script.&lt;/P&gt;&lt;PRE&gt; ambari_ldap_sync_all.sh: line 3: spawn: command not found
 ambari_ldap_sync_all.sh: line 7: send: command not found&lt;/PRE&gt;&lt;P&gt;- Please double check those packages.  Command like "spawn" comes from expect package.&lt;/P&gt;&lt;P&gt;- As you are able to run the command manually, which means these commands might now be available in your PATH variable when you are running them using cron.&lt;/P&gt;&lt;P&gt;So please fix the PATH to include the PATH to point to the location of these commands  &lt;/P&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 15:46:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-automate-ambari-LDAP-sync-through-expect-script/m-p/172369#M50192</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2016-12-27T15:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to automate ambari LDAP sync through expect script</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-automate-ambari-LDAP-sync-through-expect-script/m-p/172370#M50193</link>
      <description>&lt;P&gt;Regarding your query: &lt;EM&gt;"is there any alternative how the script can get executed automatically from crontab?"\&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt; crontab -e&lt;/PRE&gt;&lt;P&gt;
 Then add the following entry in the crontab:&lt;/P&gt;&lt;PRE&gt; 0 15 *  *  *  /PATH/TO/ambari_ldap_sync_all.sh&lt;/PRE&gt;&lt;P&gt;
 However above approach has nothing to do with HDP or Ambari. It's simple Linux.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 15:56:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-automate-ambari-LDAP-sync-through-expect-script/m-p/172370#M50193</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2016-12-27T15:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to automate ambari LDAP sync through expect script</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-automate-ambari-LDAP-sync-through-expect-script/m-p/172371#M50194</link>
      <description>&lt;P&gt;Finally I am able to resolve the issue.&lt;/P&gt;&lt;P&gt;1. I changed the script extension from ambari_ldap_sync_all.sh to ambari_ldap_sync_all.exp&lt;/P&gt;&lt;P&gt;2. I also changed the absolute path of ambari-server as /usr/sbin/ambari-server and added exit statement at the end of script.&lt;/P&gt;&lt;PRE&gt;#!/usr/bin/expect
spawn  /usr/sbin/ambari-server sync-ldap --existing
expect "Enter Ambari Admin login:"
send   "admin\r"
expect "Enter Ambari Admin password:"
send   "admin\r"
expect eof
exit&lt;/PRE&gt;&lt;P&gt;3. Finally inside the crontab, I made the entry as&lt;/P&gt;&lt;P&gt;0 23 * * * /usr/bin/expect  /opt/ambari_ldap_sync_all.exp&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2017 16:19:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-automate-ambari-LDAP-sync-through-expect-script/m-p/172371#M50194</guid>
      <dc:creator>rburagohain</dc:creator>
      <dc:date>2017-01-04T16:19:03Z</dc:date>
    </item>
  </channel>
</rss>

