Received: by 10.66.75.164 with SMTP id d4mr5261935paw.10.1349920065191; Wed, 10 Oct 2012 18:47:45 -0700 (PDT) Path: jt13ni2952pbb.1!nntp.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!fed10.iad.POSTED!not-for-mail From: Icarus Sparry Subject: Re: Give an answer to a question that is asked after a command has been run with in a script. Newsgroups: comp.unix.shell References: <8fb70ac7-3caa-413b-b8f2-25784b3dfa70@googlegroups.com> User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) MIME-Version: 1.0 Lines: 66 Message-ID: <4zpds.39110$J36.35311@fed10.iad> X-Complaints-To: abuse@usenetserver.com NNTP-Posting-Date: Thu, 11 Oct 2012 01:47:44 UTC Organization: UseNetServer - www.usenetserver.com Date: Thu, 11 Oct 2012 01:47:44 GMT X-Received-Bytes: 3507 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Wed, 10 Oct 2012 17:55:17 -0700, jgonza1495 wrote: > On Tuesday, October 9, 2012 2:57:01 PM UTC-7, (unknown) wrote: >> I run a command to start the splunk software and get asked a question. >> I want to be able to answer the question with a y within the script. I >> have tried to pass in a y but nothing happens, no y gets printed at the >> end of the question or when I try to redirect a file with the y still >> nothing happens. See the different code I have tried and output. >> [snip] > Taking the `backquotes` off just has the whole big license paragraph > scroll up but the command still does not work. It echos the y before the > question comes out, see below. I am trying to get thei sscript running > so I can deploy it to all the servers and run it to install and startup > splunk software. See below > > echo "y" | /opt/splunkforwarder/bin/splunk start > y > :::::::::::::: > /opt/splunkforwarder/license-eula.txt > :::::::::::::: > SPLUNK SOFTWARE LICENSE AGREEMENT > > THIS SPLUNK SOFTWARE LICENSE AGREEMENT (THE "AGREEMENT") GOVERNS ALL > SOFTWARE PROVIDED BY SPLUNK INC. ("SPLUNK") INCLUDING FREE SPLUNK > SOFTWARE ("FREE SOFTWARE") AND SOFTWARE PURCHASED THROUGH SPLUNK'S [ 120 more lines of license] > waiver, modification or amendment of any provision of this Agreement > will be effective only if in writing and signed by duly authorized > representatives of both parties. > Do you agree with this license? [y/n]: So it looks like /opt/splunkforwarder/bin/splunk might be a script and it is using a program such as "more" to page out the license file, and then read the user response. You could try seeing if a delay works, e.g. { sleep 3 ; echo y ; } | /opt/splunkforwarder/bin/splunk start You could see if 'expect is installed. If so then #!/usr/bin/enc expect spawn /opt/splunkforwarder/bin/splunk start expect {\[y/n]: } { send -- y\r } interact might do the trick. If you have expect then you probably also have "autoexpect", which can write this stuff for you. Just type autoexpect -p /opt/splunkforwarder/bin/splunk start do whatever you need, and then when you have finished autoexpect will write an expect program to repeat it. You could see if /opt/splunkforwarder/bin/splunk is actually a script and see if the license allows you to change it. If se just remove the test to see if you have accepted the license. You could ask Splunk Software why they require you to accept the license each time, rather than remember that you have agreed to it. If they can't even do that simple step then you might wonder how much value there is in the rest of their software.